I need to delete certain tables based on the contents of the table. I parsed the HTML using HTML::Tree to build an HTML tree.
I used replace_with_content to delete the table but that only removes the table tag and leaves the contents of the table.
Please note that the tables are nested.
my $content = get($url);
my $tree = HTML::Tree->new();
$tree->parse($content);
my (@table_tags) = $tree->look_down( '_tag' , 'table' );
my $string = $table_tags[0]->as_HTML;
my $tree2 = HTML::Tree->new();
$tree2->parse($string);
my (@table_tags2) = $tree2->look_down( '_tag' , 'table' );
$table_tags2[3]->replace_with_content();
What about using delete instead of
replace_with_content?