Im trying to validate my XML file with an external DTD. But I get this error everytime.
Document root element "A", must match DOCTYPE root "test".
i cant figure this out.
The idea of my xml file is that its need to be as short as possible . I thinkt its all good but like i said, i wont validate. Does someone have an idea ?
This is my XML file
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE test SYSTEM "test.dtd">
<A>
<B>
<F>name</F>
</B>
<D>lastname</D>
<F>name</F>
</A>
And my DTD
<!ELEMENT A (B, (C|D), E?, (F, G?)+)>
<!ELEMENT B (F|G)+>
<!ELEMENT D (#PCDATA|C)*>
<!ELEMENT F (#PCDATA)>
<!ELEMENT G (#PCDATA)>
<!ELEMENT C (#PCDATA)>
<!ELEMENT E (#PCDATA)>
Thanks
The Doctype claims the root element is <test>
but you have used <A>
<!DOCTYPE test
^^^^
Either change the Doctype so it claims the root is <A>
or change the XML and DTD to use <test>
.
<!DOCTYPE test SYSTEM "test.dtd">
Declares that the root ELEMENT of the DTD-conformant document is called test
. You want:
<!DOCTYPE A SYSTEM "test.dtd">
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With