in reply to Replacing an HTML element with multiple elements using HTML::TreeBuilder

Here's how to do your task in XML::XSH2, a wrapper around XML::LibXML I happen to maintain:

open file.xml ; for my $b in //blockquote[count(p)=1] { my $texts = xsh:split("\n\n", $b/p) ; if (count($texts) > 1) { for my $text in $texts { my $p := insert element p append $b ; insert text normalize-space($text) into $p ; } rm $b/p[1] ; } } save :b ;

map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]