#!/usr/bin/perl
use warnings;
use strict;
use XML::LibXML;
my $xmlfile = 'test.xml';
my $parser = XML::LibXML->new();
my $doc = $parser->parse_file($xmlfile);
my ($li_node) = $doc->findnodes("//li");
my ($p_element) = $doc->findnodes("//li/p");
foreach ($p_element->childNodes) {
$li_node->appendChild( $_ );
}
$li_node->removeChild( $p_element );
print $doc->toString;
####
Some text here
##
##
Some text here