Note that there are some explanatory texts on larger screens.

plurals
  1. POAn error has occurred opening extern DTD (w3.org, xhtml1-transitional.dtd). 503 Server Unavailable
    text
    copied!<p>I'm trying to do xpath queries over an xhtml document. Using .NET 3.5.</p> <p>The document looks like this: </p> <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html lang="en" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"&gt; &lt;head&gt; .... &lt;/head&gt; &lt;body&gt; ... &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Because the document includes various char entities (<code>&amp;nbsp;</code> and so on), I need to use the DTD, in order to load it with an <a href="http://msdn.microsoft.com/en-us/library/system.xml.xmlreader.aspx" rel="nofollow noreferrer">XmlReader</a>. So my code looks like this: </p> <pre><code>var s = File.OpenRead(fileToRead) var reader = XmlReader.Create(s, new XmlReaderSettings{ ProhibitDtd=false }); </code></pre> <p>But when I run this, it returns</p> <blockquote> <p>An error has occurred while opening external DTD '<a href="http://www.w3.org/TR/xhtml1-transitional.dtd" rel="nofollow noreferrer">http://www.w3.org/TR/xhtml1-transitional.dtd</a>': The remote server returned an error: (503) Server Unavailable. </p> </blockquote> <p>Now, I know <em>why</em> I am getting the 503 error. <a href="http://www.w3.org/blog/systeam/2008/02/08/w3c_s_excessive_dtd_traffic" rel="nofollow noreferrer">W3C explained it very clearly</a>. </p> <p>I've seen "workarounds" where people just disable the DTD. This is what <code>ProhibitDtd=true</code> can do, and it eliminates the 503 error. </p> <p>But in my case that leads to other problems - the app doesn't get the entity defintions and so isn't well-formed XML. How can I validate with the DTD, and get the entity definitions, without hitting the w3.org website? </p> <hr> <p>I think .NET 4.0 has a nifty built-in capability to handle this situation: the <a href="http://msdn.microsoft.com/en-us/library/system.xml.resolvers.xmlpreloadedresolver(VS.95).aspx" rel="nofollow noreferrer">XmlPreloadedResolver</a>. But I need a solution for .NET 3.5. </p> <hr> <p>related:<br> - <a href="https://stackoverflow.com/questions/2502581">java.io.IOException: Server returned HTTP response code: 503</a> </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload