Thoughts from the office by Ed Ball
Monday, March 22, 2004

When an XmlDocument of the .NET Framework is used to load an XML file that references a DTD, that DTD (and supporting files) are parsed, even if they must be downloaded over the Internet! This, in my humble opinion, is an unexpected thing, and thus a bad thing. A coworker of mine wondered why simple manipulation of an XHTML document with the correct document type declaration was taking seconds instead of milliseconds – this was why. Every element insertion seemed to be delayed by a second or so!

The problem, as documented in this blog post, is that the default XmlResolver is an instance of XmlUrlResolver. If you want to ensure that your XML document manipulation is not hampered by the downloading and/or parsing of external entities such as DTD's, be sure to set the XmlResolver property of your XmlDocument instance to null before using it.

    XmlDocument doc = new XmlDocument ();
    doc.XmlResolver = null;
3/22/2004 4:59:16 PM (Pacific Daylight Time, UTC-07:00) | Comments [0] | Code#
Name
E-mail
Home page

Comment (HTML not allowed)  

Enter the code shown (prevents robots):

Search
Archive
Links
Categories
Administration
Blogroll