Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Replace html nodes

by gsiglet (Acolyte)
on Sep 03, 2013 at 10:33 UTC ( [id://1052066]=perlquestion: print w/replies, xml ) Need Help??

gsiglet has asked for the wisdom of the Perl Monks concerning the following question:

Hello, Would it be possible to replace an html node by another one, for example:
use HTML::TreeBuilder::XPath; # Parse html my $tree = HTML::TreeBuilder::XPath->new; my $parsed = $tree->parse_content( $some_html ); # Find some node my $nodeset = $parsed->findnodes('//iframe'); for my $node (@$nodeset) { #### Would something like that be possible somehow? ### $tree->replace_by($node, $some_other_node); }
Thank you

Replies are listed 'Best First'.
Re: Replace html nodes (HTML::Element treebuilder xpath)
by Anonymous Monk on Sep 03, 2013 at 10:48 UTC
      Thank you.
      $node->replace_with( $some_other_node->detach )->delete
      is working fine
Re: Replace html nodes
by daxim (Curate) on Sep 03, 2013 at 10:50 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1052066]
Front-paged by Arunbear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2024-04-19 13:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found