Xml.XmlDocument.Load problem and don't know why???

ok i've done this before and i know how to use it, but i'm a little confused now because of the following error i'm getting. and maybe whats really confusing me is that the file is local and that i have the same code in an app that's using the 1.1 framework but for some reason the 2.0 doesn't work.

path:
"c:\documents and settings\derekklingman\desktop\20050901\reviewpwk010906.xml"

System.Net.WebException: The remote server returned an error: (407) Proxy Authentication Required.
at System.Net.HttpWebRequest.GetResponse()
at System.Xml.XmlDownloadManager.GetNonFileStream(Uri uri, ICredentials credentials)
at System.Xml.XmlDownloadManager.GetStream(Uri uri, ICredentials credentials)
at System.Xml.XmlUrlResolver.GetEntity(Uri absoluteUri, String role, Type ofObjectToReturn)
at System.Xml.XmlTextReaderImpl.OpenStream(Uri uri)
at System.Xml.XmlTextReaderImpl.DtdParserProxy_PushExternalSubset(String systemId, String publicId)
at System.Xml.XmlTextReaderImpl.DtdParserProxy.System.Xml.IDtdParserAdapter.PushExternalSubset(String systemId, String publicId)
at System.Xml.DtdParser.ParseExternalSubset()
at System.Xml.DtdParser.ParseInDocumentDtd(Boolean saveInternalSubset)
at System.Xml.DtdParser.Parse(Boolean saveInternalSubset)
at System.Xml.XmlTextReaderImpl.ParseDoctypeDecl()
at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
at System.Xml.XmlTextReaderImpl.Read()
at System.Xml.XmlLoader.LoadNode(Boolean skipOverWhitespace)
at System.Xml.XmlLoader.LoadDocSequence(XmlDocument parentDoc)
at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace)
at System.Xml.XmlDocument.Load(XmlReader reader)
at System.Xml.XmlDocument.Load(String filename)
at DsgImportation.Import.CalculateTotalXmlTags(String[] sz, String exp) in C:\Documents and Settings\derekklingman\My Documents\Visual Studio 2005\Projects\CDEnvironment\DsgImportation\Importation.vb:line 518




Answer this question

Xml.XmlDocument.Load problem and don't know why???

  • Desmond Lim

  • AngelosP

    if you can access http://dtd.elogic.com/onlinetext/v1/onlinetext.dtd from your machine without a problem, try to simply save it to a local file and addjust the dtd enterie in the XML


  • Rajesh Govindasamy

    yes the file does have a DTD and i found out that in the 2.0 framework they implements new security features that don't allow the XmlReader to use the DTD unless you set create an instance of a XmlReaderSettings class and set the ProhibitDtd to false then create a new XmlReader

    All that I found can be found at http://msdn2.microsoft.com/en-us/library/8459257a.aspx

    however i've done what they said and i'm still having problems and this is the exception i'm getting now

    System.Xml.XmlException: An error has occurred while opening external DTD 'http://dtd.elogic.com/onlinetext/v1/onlinetext.dtd': The remote server returned an error: (407) Proxy Authentication Required. ---> System.Net.WebException: The remote server returned an error: (407) Proxy Authentication Required.
    at System.Net.HttpWebRequest.GetResponse()
    at System.Xml.XmlDownloadManager.GetNonFileStream(Uri uri, ICredentials credentials)
    at System.Xml.XmlDownloadManager.GetStream(Uri uri, ICredentials credentials)
    at System.Xml.XmlUrlResolver.GetEntity(Uri absoluteUri, String role, Type ofObjectToReturn)
    at System.Xml.XmlTextReaderImpl.OpenStream(Uri uri)
    at System.Xml.XmlTextReaderImpl.DtdParserProxy_PushExternalSubset(String systemId, String publicId)
    --- End of inner exception stack trace ---
    at System.Xml.XmlTextReaderImpl.Throw(Exception e)
    at System.Xml.XmlTextReaderImpl.DtdParserProxy_PushExternalSubset(String systemId, String publicId)
    at System.Xml.XmlTextReaderImpl.DtdParserProxy.System.Xml.IDtdParserAdapter.PushExternalSubset(String systemId, String publicId)
    at System.Xml.DtdParser.ParseExternalSubset()
    at System.Xml.DtdParser.ParseInDocumentDtd(Boolean saveInternalSubset)
    at System.Xml.DtdParser.Parse(Boolean saveInternalSubset)
    at System.Xml.XmlTextReaderImpl.ParseDoctypeDecl()
    at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
    at System.Xml.XmlTextReaderImpl.Read()
    at System.Xml.XmlValidatingReaderImpl.Read()
    at System.Xml.XmlLoader.LoadNode(Boolean skipOverWhitespace)
    at System.Xml.XmlLoader.LoadDocSequence(XmlDocument parentDoc)
    at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace)
    at System.Xml.XmlDocument.Load(XmlReader reader)
    at DsgImportation.Import.CalculateTotalXmlTags(String[] sz, String exp) in C:\Documents and Settings\derekklingman\My Documents\Visual Studio 2005\Projects\CDEnvironment\DsgImportation\Importation.vb:line 524



  • STS1SS

    This is not related to the ProhibitDTD flag on the XmlReaderSettings. The XmlDocument is using XmlTextReader, which is (or should be) backwards compatible with 1.1. Based on the callstack it is parsing the DTD and it is trying to open an external DTD through a WebRequest. Can you please try if you can open the external file on your machine using only the WebRequest I suspect that might be the problem.

    You might need to provide your credentials to get through the proxy. The credentials can be set on the XmlUrlResolver - see http://msdn.microsoft.com/library/default.asp url=/library/en-us/cpref/html/frlrfsystemxmlxmlurlresolverclasscredentialstopic.asp.

    You can do this by creating a new XmlUrlResolver, setting the credentials on it, and setting it to the XmlDocument.XmlResolver property.


  • Mano Kulasingam

    You could also try plugging in your own subclass of XmlUrlResolver and override GetEntity to setup your own authenticating WebRequests then return the Response.GetResponseStream() result.
  • SevilJC

    How can I avoid XmlDocument from checking the dtd file
  • digioso

    what's in your xml file does it reference an external dtd file or something see this post

    http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=154234&SiteID=1

    or try to use a custom XmlUrlResolver, see a related post on microsoft.public.dotnet.xml

    http://groups.google.com/group/microsoft.public.dotnet.xml/browse_thread/thread/be405f41e4e158e4/122a8e219c7a7d17 lnk=st&q=xmldocument+load+GetEntity&rnum=3&hl=en#122a8e219c7a7d17



  • Xml.XmlDocument.Load problem and don't know why???