473,320 Members | 1,900 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,320 software developers and data experts.

Html parser

Hi, I am using a program that is ultra paranoid about start and end html
tags.

For example

<p>This is a test
<br>A new line

The above code causes the program to fail

<p>This is a test</p>
<br>A new line</br>

The above code works fine.

Does anyone have a short routine that looks for a start HTML tag and if a
matching end tag does not exist inserts an end tag? I could write one myself
but rather than reinventing the wheel and all that ;)

Thanks in advance
Mark
Jul 21 '05 #1
3 7700
Hi Mark,

If you look for a simple solution, you could then use Microsoft IE's HTML
parser which is pretty smart in dealing with non-closed tags. I'd also say
such a routine won't be short as the parser should keep track of each
non-closed tag and its context to suggest proper closing tags in proper
places.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"Mark" <ma**@yahoo.comN0SPAM> wrote in message
news:bj**********@lust.ihug.co.nz...
Hi, I am using a program that is ultra paranoid about start and end html
tags.

For example

<p>This is a test
<br>A new line

The above code causes the program to fail

<p>This is a test</p>
<br>A new line</br>

The above code works fine.

Does anyone have a short routine that looks for a start HTML tag and if a
matching end tag does not exist inserts an end tag? I could write one myself but rather than reinventing the wheel and all that ;)

Thanks in advance
Mark


Jul 21 '05 #2
if you need to work with existing html then consider using tidycom or the c#
wrapper for it (http://www.mattstan.pwp.blueyonder.c...y/tidycs.html),
if you're manipulating existing html then use the dom exposed by mshtml, if
you're creating html from scratch, then just use an xml dom.

r.

"Dmitriy Lapshin [C# / .NET MVP]" <x-****@no-spam-please.hotpop.com> wrote
in message news:ea**************@tk2msftngp13.phx.gbl...
Hi Mark,

If you look for a simple solution, you could then use Microsoft IE's HTML
parser which is pretty smart in dealing with non-closed tags. I'd also say
such a routine won't be short as the parser should keep track of each
non-closed tag and its context to suggest proper closing tags in proper
places.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"Mark" <ma**@yahoo.comN0SPAM> wrote in message
news:bj**********@lust.ihug.co.nz...
Hi, I am using a program that is ultra paranoid about start and end html
tags.

For example

<p>This is a test
<br>A new line

The above code causes the program to fail

<p>This is a test</p>
<br>A new line</br>

The above code works fine.

Does anyone have a short routine that looks for a start HTML tag and if a matching end tag does not exist inserts an end tag? I could write one

myself
but rather than reinventing the wheel and all that ;)

Thanks in advance
Mark

Jul 21 '05 #3
Thanks for your help
Regards
Mark
Jul 21 '05 #4

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

Similar topics

1
by: Mitchua | last post by:
I am trying to use HTML::Parser to parse an HTML file, remove all HTML tags (including comments, etc.), replace all ENTITIES (e.g. &amp), and put the result into a variable as a string. I figure...
0
by: Himanshu Garg | last post by:
Hello, I am using HTML::Parser to extract text from html pages from http://bbc.co.uk/urdu/ However the encoding of the input text seems to change to some unknown encoding in the output. The...
3
by: Himanshu Garg | last post by:
Hello, I am trying to pinpoint an apparent bug in HTML::Parser. The encoding of the text seems to change incorrectly if the locale isn't set properly. However Parser.pm in the directory...
14
by: WUV999U | last post by:
Hi I am fairly familiar in C but not much. I want to know how I can write a html parser in C that only parses for the image file in the html file and display or print all the images found in...
2
by: Craig Kenisston | last post by:
Hi, Could someone recommend any decedent html parser ? All what I need to do is to extract the links from a given page. I've found several tools in codeproject but all seems to be a bit...
3
by: Mark | last post by:
Hi, I am using a program that is ultra paranoid about start and end html tags. For example <p>This is a test <br>A new line The above code causes the program to fail
0
by: icoba | last post by:
Hi, I am parsing html documents using the html parser from libxml2, and if the encoding is included in the document it works perfectly but if it is not, I think it does not work well (probably...
3
by: SEGACO | last post by:
Hi, Can someone tell me if C# includes something to parse HTML? Thanks.
2
by: David Virgil Hobbs | last post by:
Loading text strings containing HTML code into an HTML parser in a Javascript/Jscript I would like to know, how one would go about loading a text string containing HTML code, so as to be able to...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.