Here is my code:
use XML::LibXML; my $parser = XML::LibXML->new(); my $doc = $parser->parse_file("FILE1.xml"); my @nodes_from_file1 = $doc->findnodes('//Feature'); my $new = XML::LibXML::Document->new('1.0', 'utf-8'); my $features = $new->createElement( 'Features' ); #print to debug print $features->toString; my $file1 = $new->createElement( 'File1' ); for my $node (@nodes_from_file1) { $file1->addChild( $node ); #print to debug print $file1->toString; } $features->addChild( $file1 ); print $new->toString; $new->toFile("output_new.xml")
In reply to Re^2: copy XML elements from one file to another
by Anonymous Monk
in thread copy XML elements from one file to another
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |