Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5999371
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:32:33+00:00 2026-05-23T00:32:33+00:00

Is there a way to remove an entire row (html tags ‘n all) from

  • 0

Is there a way to remove an entire row (html tags ‘n all) from an HTML Table with HTML::TableExtract?

Mucking around with the sample code from CPAN, this is what I’ve tried so far:

use HTML::TableExtract qw(tree);

my $te = HTML::TableExtract->new( headers => [qw(name type members)] );

# get $html_string out of a file...

$te->parse($html_string);

my $table = $te->first_table_found();
my $table_tree = $table->tree;
$table_tree->row(4)->replace_content('');
my $document_tree = $te->tree;
my $document_html = $document_tree->as_HTML;

# write $document_html to a file ...

Now, as the name suggests, ‘replace_content()’ in the line $table_tree->row(4)->replace_content(''); removes the content of row 4, but the row itself remains in markup. I need to get the tags and everything in-between removed as well.

Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T00:32:34+00:00Added an answer on May 23, 2026 at 12:32 am

    What you want is the parent and delete methods

    See the docs for HTML::Element and for HTML::Element::delete

    UPDATE

    Ok, click that checkmark and mark this one as answered….Here it is:

    my($p) = $table_tree->row(4)->parent();
    $p->delete;
    

    Also, NOTE, you need the () parens around $p! If you don’t have parens don’t get back a reference.

    For me, with the above Perl code working on this HTML,

    <table>
       <tr><td>name</td><td>type</td><td>members</td></tr>
       <tr><td>row1</td><td>row1</td> <td>row1</td></tr>
       <tr><td>row2</td><td>row2</td> <td>row2</td></tr>
       <tr><td>row3</td><td>row3</td> <td>row3</td></tr>
       <tr><td>row4</td><td>row4</td> <td>row4</td></tr>
    </table>
    

    I get this as a result of printing $document_html

    <table>
       <tr><td>name</td><td>type</td><td>members</td></tr>
       <tr><td>row1</td><td>row1</td><td>row1</td></tr>
       <tr><td>row2</td><td>row2</td><td>row2</td></tr>
       <tr><td>row3</td><td>row3</td><td>row3</td></tr>
    </table>
    

    Notice that there is no empty <tr></tr>

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any way to remove all forgeinKey and primary key contriants from Database
Is there any way in VB.NET to remove all of the whitespaces between tags
Is there a way to remove an item from a listbox based on a
Is there a way to remove duplicate (key-value) pairs from NSDictionary ? EDIT: My
is there any way to remove an attachment from Zend_Mail object? Simple example: $mail
Is there a way to remove all references to an object at once? I
Hi I am copying entire table rows from one html table to another. In
Is there any way to remove variable i in the following example and still
Is there any way to remove the dotted line rectangle, which indicates the keyboard
Is there a way to remove the grid header rollover in flex while still

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.