473,473 Members | 2,122 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Parsing / processing a stream of HTML

Hi,

I'm using HttpWebRequest and HttpWebResponse to return a stream of HTML.
Looking for advice as to the accepted / easiest / most efficient way to
process this HTML in the background i.e. I don't want to display it all to
the user, just pull out certain pieces of it.

Specifically, I'm looking to evaluate the tabledefs it contains - walk
through their rows and columns etc.

Any assistance gratefully received as ever.

Best regards,

Mark Rae
Nov 15 '05 #1
6 6285
Mark,
I would seriously consider using regular expressions to extract the
content you are looking for out of your html string.

http://www.regular-expressions.info/dotnet.html
http://www.ondotnet.com/pub/a/dotnet...11/regex2.html
--
Jay Douglas
Fort Collins, CO

"Mark Rae" <ma**@markrae.co.uk> wrote in message
news:uK****************@TK2MSFTNGP10.phx.gbl...
Hi,

I'm using HttpWebRequest and HttpWebResponse to return a stream of HTML.
Looking for advice as to the accepted / easiest / most efficient way to
process this HTML in the background i.e. I don't want to display it all to
the user, just pull out certain pieces of it.

Specifically, I'm looking to evaluate the tabledefs it contains - walk
through their rows and columns etc.

Any assistance gratefully received as ever.

Best regards,

Mark Rae

Nov 15 '05 #2
"Jay Douglas" <RE*********************************@squarei.com > wrote in
message news:uT****************@TK2MSFTNGP10.phx.gbl...
Mark,
I would seriously consider using regular expressions to extract the
content you are looking for out of your html string.

http://www.regular-expressions.info/dotnet.html
http://www.ondotnet.com/pub/a/dotnet...11/regex2.html


Thanks for the reply. Will that, e.g. allow me to extract all the text
between "<table" and "</table>"?

Alternatively, is there a way to reference a stream of HTML and treat it as
if it were an HTML document from which I could evaluate the tabledefs
collection etc?

Mark
Nov 15 '05 #3
Mark,

With regular expressions, you can extract text from all sorts of
different patterns including text in-between table tags.

Now about changing attributes and elements of the html string... I've
seen some examples where html is actually transformed into xml string and
then attributes of certain elements are then modified then returned back to
an html string.

Here's a link to start your research with:

http://www.fawcette.com/vsm/2002_03/..._wagner_03_18/
--
Jay Douglas
Fort Collins, CO

"Mark Rae" <ma**@markrae.co.uk> wrote in message
news:ep****************@tk2msftngp13.phx.gbl...
Thanks for the reply. Will that, e.g. allow me to extract all the text
between "<table" and "</table>"?

Alternatively, is there a way to reference a stream of HTML and treat it as if it were an HTML document from which I could evaluate the tabledefs
collection etc?

Mark

Nov 15 '05 #4
"Jay Douglas" <RE*********************************@squarei.com > wrote in
message news:e5****************@TK2MSFTNGP11.phx.gbl...

Jay,

With regular expressions, you can extract text from all sorts of
different patterns including text in-between table tags.

Now about changing attributes and elements of the html string... I've
seen some examples where html is actually transformed into xml string and
then attributes of certain elements are then modified then returned back to an html string.

Here's a link to start your research with:

http://www.fawcette.com/vsm/2002_03/..._wagner_03_18/


Thanks for this. I looked at it, and found that it was more than I needed.

In the end, I extracted the various <tr>...</tr> lines out of the HTML
stream, and then processeded them with the standard Substring() and
IndexOf() methods of the String object.

Job done.

Best,

Mark
Nov 15 '05 #5
Jay Douglas wrote:
Mark,

With regular expressions, you can extract text from all sorts of
different patterns including text in-between table tags.


Not really. You cannot match corresponding opening and closing tags for
example, because there's no way to express such constructs using regular
expressions (see context-free grammars).

I'd rather use a real parser such as the Chris Lovett's SGML parser.

http://www.gotdotnet.com/Community/U...4-C3BD760564BC

Cheers,

--
Joerg Jooss
jo*********@gmx.net

Nov 15 '05 #6
"Joerg Jooss" <jo*********@gmx.net> wrote in message
news:eC**************@TK2MSFTNGP11.phx.gbl...
Jay Douglas wrote:
Mark,

With regular expressions, you can extract text from all sorts of
different patterns including text in-between table tags.
Not really. You cannot match corresponding opening and closing tags for
example, because there's no way to express such constructs using regular
expressions (see context-free grammars).


I'm having no problems thus far extracting strings between the following
tags:

<tr>...</tr>
<td>...</td>
<p>...</p>

I'd rather use a real parser such as the Chris Lovett's SGML parser.

http://www.gotdotnet.com/Community/U...4-C3BD760564BC

Very useful!

Mark
Nov 15 '05 #7

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

Similar topics

1
by: Girish | last post by:
Hello.. I need to understand how parsing of a file or a stream(XML data in memory) takes place in Xerces C++. I am using SAX XMLReader and passing xml input as a file path or a MemBufInputSource...
0
by: creativewebpros | last post by:
I know there is a way to designate a HTML folder to export a Crystal Report's output. However, I would like to export the report to a HTML stream instead. I understand that the designated HTML...
0
by: june | last post by:
Hi, I have a big problem with parsing HTML into a XHTML using Cberneko to validate the html. First I tried to work with a HTML-File. This solutions works fine: String aHTMLFile =...
4
by: baldwasagar | last post by:
I want to parse a HTML file in Java which has JavaScript also in it. I want to fetch the data of Java Script tag also. The tag is SCRIPT. Please help with suggestions / solutions. I have tried...
29
by: lenbell | last post by:
It's old stupid and lazy here again I have been wanting to keep using my WYSIWYG (What You See Is What You Get - for my fellow stupids) html editor. But I was told that you HAD to rename your...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.