当我针对我的DTD验证我的XML文档时,我不断收到同样的错误,我无法弄清楚它为什么会发生,错误只是说: 文档根元素" Candidate_Profile",必须匹配DOCTYPE root" CV"。
<?xml version="1.0"?>
<!DOCTYPE CV [
<!ELEMENT Candidate_Profile (Personal_Details,Employment_History,Qualifications)>
<!ELEMENT Personal_Details (Surname,First_Name,Middle_Name?,Mobile_Phone,Home_Phone,Email,Address,PostCode)>
<!ELEMENT Surname (#PCDATA)>
<!ELEMENT First_Name (#PCDATA)>
<!ELEMENT Middle_Name (#PCDATA)>
<!ELEMENT Mobile_Phone (#PCDATA)>
<!ELEMENT Home_Phone (#PCDATA)>
<!ELEMENT Email (#PCDATA)>
<!ELEMENT Address (#PCDATA)>
<!ELEMENT PostCode (#PCDATA)>
<!ELEMENT Employment_History (#PCDATA)>
<!ELEMENT Qualifications (#PCDATA)>
]>
<Candidate_Profile>
<Personal_Details>
<Surname>Meacham</Surname>
<First_Name>Sofia</First_Name>
<Mobile_Phone>077111111</Mobile_Phone>
<Home_Phone>012222222</Home_Phone>
<Email>sofia@xxxxxx</Email>
<Address>Romsey</Address>
<PostCode>SO</PostCode>
</Personal_Details>
<Employment_History>Uni 1, Companies</Employment_History>
<Qualifications>Several</Qualifications>
</Candidate_Profile>
答案 0 :(得分:0)
尝试我在评论中提到的两件事,然后将简历更改为候选人资料
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Candidate_Profile
[
<!ELEMENT Candidate_Profile (Personal_Details,Employment_History,Qualifications)>
<!ELEMENT Personal_Details (Surname,First_Name,Middle_Name?,Mobile_Phone,Home_Phone,Email,Address,PostCode)>
<!ELEMENT Surname (#PCDATA)>
<!ELEMENT First_Name (#PCDATA)>
<!ELEMENT Middle_Name (#PCDATA)>
<!ELEMENT Mobile_Phone (#PCDATA)>
<!ELEMENT Home_Phone (#PCDATA)>
<!ELEMENT Email (#PCDATA)>
<!ELEMENT Address (#PCDATA)>
<!ELEMENT PostCode (#PCDATA)>
<!ELEMENT Employment_History (#PCDATA)>
<!ELEMENT Qualifications (#PCDATA)>
]>
<Candidate_Profile>
<Personal_Details>
<Surname>Meacham</Surname>
<First_Name>Sofia</First_Name>
<Mobile_Phone>077111111</Mobile_Phone>
<Home_Phone>012222222</Home_Phone>
<Email>sofia@xxxxxx</Email>
<Address>Romsey</Address>
<PostCode>SO</PostCode>
</Personal_Details>
<Employment_History>Uni 1, Companies</Employment_History>
<Qualifications>Several</Qualifications>
</Candidate_Profile>
值得一试W3Schools