XML DocumentType method CreateDocumentType crashes if DTD is absent .NET C#

HetEmumejem

New Member
I have a problem with generating an XML that needs to be generated automatically and then manually uploaded on a client site for validation.The specification of the client requires that we include the DTD declaration at the top.That is\[code\]<!DOCTYPE TheFile System "TheDTD.dtd" ""> \[/code\]So programmatically when I try to generate the XML the line \[code\] XmlDocumentType doctype; doctype = doc.CreateDocumentType("TheFile", null, "TheDTD.dtd", null); doc.AppendChild(doctype);\[/code\]Fails and it asks me the "TheDTD.dtd" should exist in the windows directory:C:\Windows\System32\inetsrvLater if I want to read the XmlDoc the line\[code\] XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(xmlLocation);\[/code\]Fails and it asks me the "TheDTD.dtd" should exist in the Project directory where the whole project is storedI don't want to actually validate the DTD, I just want to reference because the validation happens on the client side. Is there any way to add the line " " in the XML without having to copy the actual .dtd in 2 different locations?If we make the declaration public and change this to \[code\] <!DOCTYPE TheFile PUBLIC "TheDTD.dtd" ""> \[/code\]then everything works fine but the client requires that it should be SYSTEM and not PUBLIC.I wish the CreateDocumentType and the Load method wouldn't crash if the actual .dtd is missing because at this point I don't even have this file and it's not needed for my purposes.Thank you
 
Back
Top