all groups > dotnet xml > february 2006 >
You're in the

dotnet xml

group:

Parsing XHTML


Parsing XHTML gizap NO[at]SPAM poczta.onet.pl
2/23/2006 3:45:21 AM
dotnet xml:
I'm trying to parse an XHTML document like this:

file.html:
<?xml version="1.0" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Some title</title>
</head>
<body>
<p>Some text</p>
</body>
</html>

with the following code:

XmlReaderSettings xs = new XmlReaderSettings();
xs.ProhibitDtd = false;
XmlReader reader = XmlReader.Create("file.html", xs);
reader.MoveToContent();

The last line generates the following exception:
An error has occurred while opening external DTD
'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd': Unable to connect
to the remote server

There is no difference if I'm using XmlReader, XmlDocument.Load...
There is no difference if I'm loading XML from file or from string...

The following line:
xs.ProhibitDtd = true;
produces of course an exception:
For security reasons DTD is prohibited in this XML document. To enable
DTD processing set the ProhibitDtd property on XmlReaderSettings to
false and pass the settings into XmlReader.Create method.

Ok, but I need this DTD! :)

How to do it?
Re: Parsing XHTML Martin Honnen
2/23/2006 1:47:27 PM


[quoted text, click to view]

Works for me if I am connected to the internet. Are you connected? How?
Is there any proxy used?
Make sure there is no code setting the property
xs.XmlResolver
to null.


--

Martin Honnen --- MVP XML
AddThis Social Bookmark Button