0
Answer

Processing/Ignoring DTD present in XML file using C# App

Ask a question

Hi,

I have some input Xml files. They have inline dtd reference in them pointing to the dtd files in one of the local drives.

I wanted to take out Xpaths from those Xml files. So, i wrote a Stylesheet which would extract Xpaths out of the xml files.

By using a small C# Console Application , am trying to transform the Xml files by applying Stylesheet on them and generate the Xpaths.

 

I am successfully able to generate the Xpaths. However, not all Xpath are from xml files, some of them dont even exist in those files. As far as i think , the Application is generating the paths from the file as well as probable Xpaths from the DTD. Can anyone shed some light on this?

 

Below is the code i used in my app:


Code.jpg


Since i am not very sure of how the extra Xpaths are getting generated, i also tried to generate Xpath by ignoring the DTD.

 

For this, i have changed the

ProhibitDTD property =  true and set XmlResolver Property of XmlReaderSetting to null 

rdSett.XmlResolver = null;

But this also doesnt work. It gives the error "For security reasons DTD is prohibited in this XML document. To enable DTD processing set the ProhibitDtd property on XmlReaderSettings to false and pass the settings into XmlReader.Create method."

 

Any ideas on either way (processing DTD and getting Xpath only from Xml file / Ignoring DTD and getting Xpath from Xml file) will be helpful.

 

Thanx,

Sid