开发者

XML file with DTD displays fine in web browser after invalid change

I am new to XML and DTD. I have written an XML file with DTD. Here is it.

<?xml version="1.0"?>
<!DOCTYPE  note[
     <!ELEMENT note (page , author ,company)>
     <!ELEMENT page (#PCDATA)>
     <!ELEMENT author (#PCDATA)>
     <!ELEMENT company (#PCDATA)>
     <!ATTLIST note type CDATA #IMPLIED>
]>

<note typ="single">
    <page>1000</page>
    <author>devan</author>
    <author>devan</author>
    <company>IDM</co开发者_如何学编程mpany>
</note>

It works fine. But my problem is, if you set the note attribute as typ it displays the result in the web browser just fine. But in the DTD it defines <!ATTLIST note type CDATA #IMPLIED>.

And whenever I change the tags in xml <pag>fhdh </pag> it displays in the web browser just fine. My problem is then why do we define DTD?


DTD by itself only defines what a valid XML looks like.

If you run the sample XML in the question through an XML validator, it will not be considered valid for the DTD you specified in the question.


Here are some reasons ...

http://csharpcomputing.com/XMLTutorial/Lesson8.htm

http://www.htmlbasictutor.ca/doctype-declaration.htm

And a PDF: DTD for XML

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜