How to set ProhibitDtd to false?

Posted on 2006-05-07
Medium Priority
Last Modified: 2008-03-03
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?
Question by:maximyshka
  • 4
  • 2
LVL 11

Expert Comment

ID: 16631727
Check your !DOCTYPE declaration node:


Author Comment

ID: 16632621
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.
LVL 11

Expert Comment

ID: 16632876

Can you please post a line that causes the error?
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.


Author Comment

ID: 16827831
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.
LVL 11

Accepted Solution

TornadoV earned 2000 total points
ID: 16832903
This should be helpful, look for "Performing the Transformation" and "Whitespace Handling" sections:

LVL 11

Expert Comment

ID: 16870885
Try this:

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

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses
Course of the Month16 days, 22 hours left to enroll

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question