An error has occurred opening extern DTD (w3.org, xhtml1-transitional.dtd). 503 Server Unavailable
- by Cheeso
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 ( 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