Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / XML / July 2006

Tip: Looking for answers? Try searching our database.

XmlDocument load question

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
supercodepoet@gmail.com - 17 Jul 2006 16:52 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?
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?

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.