On 6/2/05, Nilay   Puri, Noida wrote:
> Hi All,
> 
> while reading a html file from perl script, I want to ensure that all HTML
> tags have closing HTML tags.
> If closing HTML tags are not there, then, I need to put the closing tag in
> place.
> 
> Can anyone guide in this regard ?
> 
> Thanks & Regards.
> 

There is no way, even in theory, to *always* correctly close an open
HTML tag. Here's a trivial example:
   <p>some text <strong>some more text</p>
Can any program correctly close the <strong> tag? Should it close the
"some" word or all of the remaining text until the </p>?

You can use HTML::Parser (http://search.cpan.org/dist/HTML-Parser/) to
parse the HTML and use "if" statements to check for a missing closing
tag. I think this will be very hard :)
I think you are better of using an existing tool to "clean up" your
HTML. Although not a Perl tool, I recommend "HTML Tidy":
http://tidy.sourceforge.net/

HTH,
-- 
Offer Kaye

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to