An error has occurred opening extern DTD (w3.org, xhtml1-transitional.dtd). 503 Server Unavailable

Posted by Cheeso on Stack Overflow See other posts from Stack Overflow or by Cheeso
Published on 2010-04-01T03:49:20Z Indexed on 2010/04/01 3:53 UTC
Read the original article Hit count: 528

Filed under:
|
|
|
|

I'm trying to do xpath queries over an xhtml document.

The document looks like this:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
  <head>
   ....
  </head>
  <body>
    ...
  </body>
</html>

Because the document includes various char entities (&nbsp; and so on), I need to use the DTD, in order to load it with an XmlReader. So my code looks like this:

var reader = XmlReader.Create(sr, new XmlReaderSettings { ProhibitDtd = false });

But when I run this, it returns

An error has occurred while opening external DTD 'http://www.w3.org/TR/xhtml1-transitional.dtd': The remote server returned an error: (503) Server Unavailable.

Now, I know why I am getting the 503 error. W3C explained it very clearly.

But I still want to validate the document. How can I validate with the DTD, and get the entity definitions, without hitting the w3.org website?


related:
- java.io.IOException: Server returned HTTP response code: 503

© Stack Overflow or respective owner

Related posts about .NET

Related posts about XHTML