I have cXml document I want to load to parse. The document has a
DOCTYPE element that points to an external dtd via http. When the
document loads it trys a web request which I am assuming is to get the
dtd. We have a proxy and this throws and exception when trying to load
the document becuase it could not authenticate through the proxy. Is
there anyway I can turn off the download?
Martin Honnen - 17 Jul 2006 17:05 GMT
> I have cXml document I want to load to parse. The document has a
> DOCTYPE element that points to an external dtd via http. When the
> document loads it trys a web request which I am assuming is to get the
> dtd. We have a proxy and this throws and exception when trying to load
> the document becuase it could not authenticate through the proxy. Is
> there anyway I can turn off the download?
XmlDocument has a property XmlResolver which you can set as needed to a
resolver so you can do e.g.
XmlDocument xmlDocument = new XmlDocument();
XmlUrlResover urlResolver = new XmlUrlResolver();
// set proxy and/or credentials on resolver as needed
xmlDocument.XmlResolver = urlResolver;
// now call Load method e.g.
xmlDocument.Load(@"file.xml");

Signature
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Thomas S - 30 Jul 2006 00:37 GMT
I had the same problem reading from a cxml doc. I did this:
XmlReaderSettings setts = new XmlReaderSettings();
setts.ValidationType = ValidationType.None; // no DTD validation
setts.XmlResolver = null; // do not even download the DTD
setts.ProhibitDtd = false; // to avoid an exception due to the presence of a
DTD in the XML doc
Encoding encode = System.Text.Encoding.GetEncoding("utf-8");
// pipe the stream to a higher level stream reader with the required
encoding format
StreamReader rstrm = new StreamReader(memstrm, encode);
// create the base reader object. necessary to apply the above settings
XmlReader xread = XmlReader.Create(rstrm, setts);
>I have cXml document I want to load to parse. The document has a
> DOCTYPE element that points to an external dtd via http. When the
> document loads it trys a web request which I am assuming is to get the
> dtd. We have a proxy and this throws and exception when trying to load
> the document becuase it could not authenticate through the proxy. Is
> there anyway I can turn off the download?