How to set ProhibitDtd to false?

Posted on 2006-05-07
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
    LVL 11

    Expert Comment

    Check your !DOCTYPE declaration node:

    Author Comment

    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


    Can you please post a line that causes the error?

    Author Comment

    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

    This should be helpful, look for "Performing the Transformation" and "Whitespace Handling" sections:
    LVL 11

    Expert Comment

    Try this:

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

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Suggested Solutions

    Title # Comments Views Activity
    Reduced with of radio button in the page 2 28
    call function 8 34
    popup message 3 17
    Linking dictionary and columns together 2 35
    Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
    Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    737 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

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now