So, basically a single node "testsuite" which contains several "testcases" in each file. So I basically want to extract the "testsuite" node from each file and put it into a new file. I also would like to modify the attribute "name" of each testsuite. So far I have:<testsuites> <testsuite name="test_suite_name" ...> <testcase name="test1" .../> <testcase name="test2" .../> <testsuite name="some_name" ...> </testsuites>
$testsuite1 is a XML::LibXML::NodeList object type. Is there a way to use that object to inject it in some way to $doc?my $dom = XML::LibXML::Document->new('1.0', 'utf-8'); my $xml1 = XML::LibXML->load_xml(location => 'file1.xml'); my $xml2 = XML::LibXML->load_xml(location => 'file2.xml'); my $root = $dom->createElement('testsuites'); $dom->setDocumentElement($root); my $testsuite1 = $xml1->findnodes('//testsuite'); my $testsuite2 = $xml2->findnodes('//testsuite'); my $child = $dom->createElement($testsuite1); # <-- fails $root->appendChild($child); open XML, ">result.xml"; print XML $dom->toString(); close XML;
In reply to Parsing XML data and injecting it into new file by hosselausso
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |