Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old February 23rd, 2006, 11:55 AM
gizap@poczta.onet.pl
Guest
 
Posts: n/a
Default Parsing XHTML

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?

  #2  
Old February 23rd, 2006, 01:05 PM
Martin Honnen
Guest
 
Posts: n/a
Default Re: Parsing XHTML



gizap@poczta.onet.pl wrote:
[color=blue]
> 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[/color]

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
http://JavaScript.FAQTs.com/
 

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles