XML with DTD

Hello guys!

I don’t know if I’m doing mistakes but I can not validate an xml instance on a DTD. I’ve tried to use it in a simple example but it didn’t work as I wanted.

Here is my DTD:

<!ELEMENT oasis (album+)>
<!ELEMENT album (music+)>
<!ELEMENT music (#PCDATA)>

And here, my xml:

<?xml version="1.0"?>
<!DOCTYPE oasis SYSTEM "oasis.dtd">
    <album name="The Heathen Chemistry">
        <music track="2">Force of Nature</music>
        <music track="9">She is Love</music>

The xml is ok, just like was defined at the DTD. But if I put one more tag (i.e. ) after , the browser don’t show me any error message.

Where am I doing mistake?


Marcus Vin

Hello there,

You stated :

the browser don’t show me any error message

By browser do you mean Internet Explorer or Firefox ? Those softwares provide some “advanced” features do display XML (folding/unfolding). They check well-formness of XML documents BUT they are not validant, they WON’T check that your XML document follows the rules of your DTD/Schema.

If you want to check that you XML document is valid, use XMLSpy, Oxygen or another tool of your choice.


Now I understand how it works…

Thanks a lot man!