Using my module, I can reproduce the HTML I was given and
supress the printing of certain tags, and print tags only to
a given level:
use YAPE::HTML;
$p = YAPE::HTML->new($CONTENT);
1 while $p->next; # to build the tree
@exclude = qw( a img );
$level = 2;
for ($p->root) { # top-level elements
print $_->fullstring(\@exclude, $level);
}
I'm adding a feature to change it from allowing an exclude
list to allowing either an exclude list or an "exclude all
except..." list. If the previous code was given:
<b>Hi <i>there <s>folks!</s></i></b>
<br><br>
Visit my <img src="naked_woman.jpg"><a
href="http://www.pornsite.com/">porn site</a>!
then output would be:
<b>Hi <i>there folks!</i></b>
<br><br>
Visit my porn site!
The <s> tag was removed because it was 3
layers down, and I requested only 2 layers.
japhy --
Perl and Regex Hacker |