• 0

Defining DTD for an XMLDocument ?


Question

Hello again,

Is there any way to define a DTD for an XML file ? I have a set of 12.000 files, all without DTD's defined in the files. The files does have a DTD to validate against, and I need C# to be able to use this file to validate the XML files against.

Is there any way of defining this, without having to insert a doctype in all the xml files ? (I know I can do this with xslt, but thats out of the question).

Thanks,

.:BoeManE:.

Link to comment
Share on other sites

8 answers to this question

Recommended Posts

  • 0
http://www.w3schools.com/dtd/default.asp

Not sure if the XML classes of .NET use the DTD for validation.

I know what a DTD is, and the C# DOM Parser will parse an XML file with the DTD if it is defined inline in the code. But since none of the 12.000 files I have have a DTD reference, And since I'm not able to add them to the files, I need to be able to define a DTD to the C# XML Parser...

something like

XmlTextReader reader = new XmlTextReader(filename);

reader.setDocumentType(dtdfile);

But I haven't been able to find such a thing in the API...

.:BoeManE:.

Link to comment
Share on other sites

  • 0

Ah. AFAIK you can only feed XSD schemas to the XML classes (only those that perform validation), no DTDs. If the existing DTD isn't too complex, you'd better rewrite it as XSD if you really need validation.

Link to comment
Share on other sites

  • 0
Ah. AFAIK you can only feed XSD schemas to the XML classes (only those that perform validation), no DTDs. If the existing DTD isn't too complex, you'd better rewrite it as XSD if you really need validation.

Seriously. This sux. For each part of my application that I'm developing, the C# API returns a wall...

I miss being able to program in Java... :(

.:BoeManE:.

Link to comment
Share on other sites

  • 0

I would have sworn that there was a way to do it. Apparently not. Still, it wouldn't be hard to modify those file programmatically to insert the element. It'd be a lot quicker than hand modifying them.

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.