XmlTextReader not able to find DTD file

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?iso-8859-1?Q?Eivind_Gussi=E5s_L=F8kseth?=

    #1

    XmlTextReader not able to find DTD file

    I'm having trouble with an ASP.NET application used to receive XML content
    over http. The application gets the XML content as the HttpWebRequest
    content, and the XML document references a DTD file for XML validation. I
    have the DTD file in the Bin folder, but that's not where .NET expects it to
    be.

    When debuggin, I found that the path where .NET was looking for the DTD
    file, was the path of the IIS process (C:\Windows\Sys tem32\inetsrv\) , so I
    copied the DTD file to that folder, and everything seemed to work just fine.
    And it did so in the production environment too, until it started to look
    for the DTD file from some folder beneath the ftproot folder! I suppose it's
    the last (current) folder used by IIS for some FTP session.

    I guess I need a way to explicitly tell where the DTD file is. The exception
    occures when i call the Load() method of an XmlDocument object. Can someone
    help me out with this?

    BTW, the XML content looks like this:

    <?xml version="1.0" encoding="ISO-8859-1"?<!DOCTYPE MSGLST SYSTEM
    "pswincom_repor t_request.dtd">
    <MSGLST><MSG><I D>1</ID><REF>9818352 0</REF><RCV>479321 3244</RCV><STATE>DELI VRD</STATE></MSG></MSGLST>

  • Martin Honnen

    #2
    Re: XmlTextReader not able to find DTD file

    Eivind Gussiås Løkseth wrote:
    I guess I need a way to explicitly tell where the DTD file is. The
    exception occures when i call the Load() method of an XmlDocument
    object. Can someone help me out with this?
    >
    BTW, the XML content looks like this:
    >
    <?xml version="1.0" encoding="ISO-8859-1"?<!DOCTYPE MSGLST SYSTEM
    "pswincom_repor t_request.dtd">
    <MSGLST><MSG><I D>1</ID><REF>9818352 0</REF><RCV>479321 3244</RCV><STATE>DELI VRD</STATE></MSG></MSGLST>
    You can set a custom XmlResolver:
    http://msdn.microsoft.com/en-us/libr...lresolver.aspx
    One way to do that is to subclass XmlUrlResolver where the subclass
    overrides the GetEntity and ResolveUri methods and makes sure that for
    the URI pswincom_report _request.dtd the DTD is loaded from the location
    where you stored it.


    --

    Martin Honnen --- MVP XML
    http://JavaScript.FAQTs.com/

    Comment

    Working...