Search code examples
exceptionxpathdocument

Why do I get web exception when creating an XPathDocument?


Creating an XPathDocument with referenced DTD sometimes throws a web exception. Why?


Solution

  • See http://todotnet.com/archive/2006/07/27/8248.aspx

    Because in the construction of XPathDocument, there's an http GET command to see if it can access the DTD. It's not doing anything with the DTD. It's for just in case. So while XPathDocument is initially set up to be a faster alternative to XmlDocument, you'll have the additional overhead of an http request that needs to be resolved. Imagine that server being on the other side of the globe!