Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Validating XML using DTD in .NET

Status
Not open for further replies.

cjdrake

Programmer
Jul 11, 2003
30
0
0
GB
Hi,

I've been using .NET for ages now but recently have started using it in conjunction with XML.

I have a v.simple XML document with DOCTYPE reference to my DTD at the top which I wish to validate the XML against, however when I load the XML into a XMLDocument object I get the following error:

System.Xml.XmlException: The expected DTD markup was not found. Line 1, position 3.

My XML file is:

<!DOCTYPE note SYSTEM "<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>

My DTD is:

<!DOCTYPE note [

<!ELEMENT note (to,from,heading,body)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT heading (#PCDATA)>
<!ELEMENT body (#PCDATA)>

]>

I'm guessing it's some sort of path issue, I've also tried the absolute C:\ path ref for the dtd file without luck.

If anyone can point me in the right direction it will be much appreciated!

Thanks in advance,
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top