#! /usr/bin/perl use strict; use warnings; use HTML::TreeBuilder; my $t = HTML::TreeBuilder->new_from_file(*DATA) or die qq{cant build tree: $!\n}; my @anchors = $t->look_down(_tag => q{a}); for my $anchor (@anchors){ if ($anchor->as_text eq q{NEXRAD Level III}){ $anchor->replace_with_content; } } print $t->as_HTML( undef, q{ }, {}, ); $t->delete; __DATA__ <TABLE width=745 BORDER=0 CELLPADDING=2 cellspacing=0> <TR> <TD colspan=4 bgcolor=green align=center cellpadding=0> <font color=green>.</font> </TD> </TR> <TR> <TD width=25% rowspan=4 BGCOLOR="#DEB887" align=center> <p id="entrypor"><font color=#127d37 face=Helvetica size=3><B>Radar&nb +sp;</font></B><a href="#more-radar" onclick="moreradar()" title="Clic +k to show products and output type selction options.">[-]</a></p> </TD> <TD bgcolor="white" width=35% valign=middle align=left> &nbsp;<span id="entrylinks"><A HREF="HAS.FileAppSelect?datasetname=650 +0">NEXRAD Level II</A></span> </TD> <TD bgcolor="white" width=20% valign=middle align=left> <span id="accesslinkage"><i><A HREF="HAS.FileAppSelect?datasetname=650 +0">access</A> | <A HREF="http://www.ncdc.noaa.gov/oa/documentlibrary/ +surface-doc.html#6500" target="infowin">info</A> | inv | <A HREF="htt +p://www.ncdc.noaa.gov/oa/documentlibrary/index.php?choice=dsi&searchs +tring=6500&submitted=1&submitted=Search" target="docwin">docs</A></I> +</span> </TD> <TD bgcolor="white" width=20% valign=middle align=right> <span id="entrypor">06/05/1991 - 06/15/2009</span> </TD> </tr> <TR> <TD bgcolor="#eaeaea" width=35% valign=middle align=left> &nbsp;<span id="entrylinks"><A HREF="HAS.FileAppSelect?datasetname=700 +0">NEXRAD Level III</A></span> </TD> <TD bgcolor="#eaeaea" width=20% valign=middle align=left> <span id="accesslinkage"><i><A HREF="HAS.FileAppSelect?datasetname=700 +0">access</A> | <A HREF="http://www.ncdc.noaa.gov/oa/documentlibrary/ +surface-doc.html#7000" target="infowin">info</A> | inv | <A HREF="htt +p://www.ncdc.noaa.gov/oa/documentlibrary/index.php?choice=dsi&searchs +tring=7000&submitted=1&submitted=Search" target="docwin">docs</A></I> +</span> </TD> <TD bgcolor="#eaeaea" width=20% valign=middle align=right> <span id="entrypor">05/07/1992 - 06/14/2009</span> </TD> </tr> <TR> </TR> </table>
output (extract plus whitespace)
<td align="left" bgcolor="#eaeaea" valign="middle" width="35%"> &nbsp; <span id="entrylinks">NEXRAD Level III</span> </td>

In reply to Re: Parsing HTML by wfsp
in thread Parsing HTML by deadpickle

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.