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
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.