From: mathew
Date: 2005-06-28T01:45:39+09:00
Subject: Re: Best way to parse/update HTML file?
Bucco wrote:
> Sorry for the newbie question. I am trying to find the best metod for
> parsing a HTML file and changinf one tag/item. Unfortunately, REXML
> chokes on the file because of the incomplete tags. Completing the tag
> is not an option either. What is the best way to find a specific tag
> in an html file, change it's text and attribute settings?
For invalid "tag soup" HTML, your best bet is probably to use
html/htmltokenizer.
It'll search for specified 'tags', returning the text skipped over,
which you can put into a buffer. Then you can get the attributes of the
'tag', and modify them, and put the result in the buffer. Finally, you
can slurp in the rest of the pseudo-HTML.
mathew