I have several xml files from where I want to read data and put it together in a single xml file.
The origin files look all like this like this:
<testsuite name="test_suite_name" ...>
<testcase name="test1" .../>
<testcase name="test2" .../>
<testsuite name="some_name" ...>
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:
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');
my $testsuite1 = $xml1->findnodes('//testsuite');
my $testsuite2 = $xml2->findnodes('//testsuite');
my $child = $dom->createElement($testsuite1); # <-- fails
open XML, ">result.xml";
print XML $dom->toString();
is a XML::LibXML::NodeList
Is there a way to use that object to inject it in some way to $doc?