Link to home
Start Free TrialLog in
Avatar of maximyshka
maximyshka

asked on

How to set ProhibitDtd to false?

When I'm trying to use an xsl file on an xml output of my program, I get the following error:

Exception Details: System.Xml.XmlException: 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.

It's pretty clear, but the problem is... I do not have an xmlReader anywhere. All I do is get an XmlDataDocument, and then process it with XslCompiledTransform. Where is the XmlReader whose settings I should change?  Is it created behind the scenes by one of these two classes?  How do I access it?
Avatar of TornadoV
TornadoV
Flag of United States of America image

Check your !DOCTYPE declaration node:

http://codecomments.com/XML/message849807.html
Avatar of maximyshka
maximyshka

ASKER

Tornado,
I don't see any !DOCTYPE in my XML. This is the only line on top of the XML file that my program generates:
<?xml version="1.0" encoding="utf-8"?>

The rest of it is xml data itself (customers with their info).

Any ideas? Maybe I don't understand the whole !DOCTYPE thing?  The article you sent is a little bit unclear regarding what actually solved the problem.
Max,

Can you please post a line that causes the error?
Apologies for the delay, there's been a break in our work.  It seems that the line, which causes error is located in XSL document, created by a designer, and the xsl he made is proper and definitely works (it's been tested by him on other xsl processors). All I have to do, is somehow remove that Dtd Prohibition in my program.
ASKER CERTIFIED SOLUTION
Avatar of TornadoV
TornadoV
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Try this:

XmlDocument doc = new XmlDocument();
doc.XmlResolver = null;
doc.Load(yourdocument);