Wednesday, August 08, 2007

System.Net.WebException from XmlDocument.Load

I had a really bizzare problem today - I was loading a local XML document via XmlDocument.Load and it was throwing a System.Net.WebException - The remote server returned an error: (503) Server Unavailable.

I was totally stumped, and then I hapened to open the XML document in question (it's actually an XHTML document), and I noticed that the first line was a DOCTYPE with a link to an external DTD.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

Sure enough, following the link gave me a 503 Server Unavailable error!

To resolve the problem I simply removed the DOCTYPE from the HTML document.

No comments: