473,387 Members | 1,501 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

reading xhtml documents offline

Hi!
I'm trying to parse an xhtml document like this:

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

</title></head>
<body>
<dl>
<dt>NAME</dt><dd>VARIANTATTRIBUTE1</dd><dt>TYPE</dt><dd>STRING</dd><dt>VALUE</dt><dd>HEY</dd><dt>LOCKVALUE</dt><dd>31314D32444F2F485A4E6C414A47474B62734B53524 56F676A2F673D</dd><dt>HOME</dt><dd><a href="/v1/boards/DNUMBOARD05/wgs/01/variants/B1/attributes/VARIANTATTRIBUTE1">VARIANTATTRIBUTE1</a></dd><dt>VARIANT</dt><dd><a href="/v1/boards/DNUMBOARD05/wgs/01/variants/B1">B1</a></dd>
</dl>
</body>
</html>

The problem is that XmlDocument.Load("<!..."); tries to access the DTD and this takes ages. On the other hand, the browser can display this page quickly.
Is it possible at all to read this xhtml document offline?
Can I somehow tell the Document object the contents of the DTD? then I could store it as a string in the assembly.

Lots of Greetings!
Volker
--
For email replies, please substitute the obvious.
Oct 7 '08 #1
2 1825
Volker Hetzer schrieb:
Hi!
I'm trying to parse an xhtml document like this:
[...]
The problem is that XmlDocument.Load("<!..."); tries to access the DTD
and this takes ages. On the other hand, the browser can display this
page quickly.
Is it possible at all to read this xhtml document offline?
Can I somehow tell the Document object the contents of the DTD? then I
could store it as a string in the assembly.
Found out.
There is a nice explanation with a downloadable project here:
http://blogs.pingpoet.com/overflow/a...7/20/6607.aspx .
I just had to modify it not to create its own DTD.

Lots of Greetings!
Volker
--
For email replies, please substitute the obvious.
Oct 7 '08 #2
Volker Hetzer wrote:
I'm trying to parse an xhtml document like this:

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

</title></head>
<body>
<dl>

<dt>NAME</dt><dd>VARIANTATTRIBUTE1</dd><dt>TYPE</dt><dd>STRING</dd><dt>VALUE</dt><dd>HEY</dd><dt>LOCKVALUE</dt><dd>31314D32444F2F485A4E6C414A47474B62734B53524 56F676A2F673D</dd><dt>HOME</dt><dd><a
href="/v1/boards/DNUMBOARD05/wgs/01/variants/B1/attributes/VARIANTATTRIBUTE1">VARIANTATTRIBUTE1</a></dd><dt>VARIANT</dt><dd><a
href="/v1/boards/DNUMBOARD05/wgs/01/variants/B1">B1</a></dd>
</dl>
</body>
</html>

The problem is that XmlDocument.Load("<!..."); tries to access the DTD
and this takes ages. On the other hand, the browser can display this
page quickly.
Is it possible at all to read this xhtml document offline?
It depends on whether the document references entities defined in the
DTD. If it does not do that then doing
XmlDocument doc = new XmlDocument();
doc.XmlResolver = null
doc.Load("doc.xhtml");
should suffice to avoid that the XML parser fetches the DTD.

If the document however references entitities with e.g. &auml; then you
would get an error about an a reference to an undefined entity if the
parser has not fetched the DTD.

In that case if you want to speed up parsing your XHTML documents you
should store local copies of the DTD and all files it references and
then write your own XmlResolver (for instance by subclassing
XmlUrlResolver) that makes sure that the local copies are fetched when
the identifiers like "-//W3C//DTD XHTML 1.0 Transitional//EN" are resolved.
Can I somehow tell the Document object the contents of the DTD? then I
could store it as a string in the assembly.
That has been done I think, google for .NET XmlResolver assembly.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Oct 7 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

32
by: jp29 | last post by:
My take on problems composing, serving and rendering XHTML documents/web pages: 1. Typical conscientious web authors are producing XHTML documents (Web pages) that feature valid Markup and with...
82
by: Buford Early | last post by:
I read this in http://annevankesteren.nl/2004/12/xhtml-notes "A common misconception is that XHTML 1.1 is the latest version of the XHTML series. And although it was released a bit more than a...
17
by: Christoph Schneegans | last post by:
Hi! I would like to announce XHTML Proxy, a service that allows more accurate testing of XHTML documents. <http://hixie.ch/advocacy/xhtml> states that "Sending XHTML as text/html Considered...
11
by: Kidogg | last post by:
Hi all, I'm attempting to write a validator for some email template files we use as part of our e-commerce application (incidentally in C#) and I've run into a problem as I'm not a huge user of...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.