in reply to Re: copy XML elements from one file to another
in thread copy XML elements from one file to another
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")
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: copy XML elements from one file to another
by tangent (Parson) on Nov 26, 2013 at 17:30 UTC | |
by Anonymous Monk on Nov 26, 2013 at 23:26 UTC |