in reply to Replacing an HTML element with multiple elements using HTML::TreeBuilder
use Web::Query::LibXML qw(); my $w = Web::Query->new_from_html(<<'HTML'); <body> … HTML $w->find('blockquote p')->each(sub { my @parts = split ' ', $_->text; if (@parts > 1) { for my $p (reverse @parts) { $_->after("<p>$p</p>"); } $_->remove; } }); print $w->as_html; __END__ … <blockquote id="two"><p>ddd</p><p>eee</p><p>fff</p></blockquote> …
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Replacing an HTML element with multiple elements using HTML::TreeBuilder
by Anonymous Monk on Jul 04, 2019 at 04:01 UTC |