I have a Perl program to parse an input XML file and print values to an output text file.
It seems to work fine when I build with the DWIM Perl GUI, but when I build the same with ActivePerl it fails due to missing libraries.
Can someone help me converting the code to the ActivePerl equivalent?
The Perl code is
use strict;
use warnings;
use XML::LibXML;
open( my $File, '>', 'options.txt' );
my $filename = $ARGV[0];
my $parser = XML::LibXML->new();
my $xmldoc = $parser->parse_file( $filename );
for my $sample ( $xmldoc->findnodes( '/Releases/Release' ) ) {
foreach my $child ( $sample->getChildnodes ) {
if ( $child->nodeType() == XML_ELEMENT_NODE ) {
print $File $child->textContent(), " ";
}
}
print $File "\n";
}
My Input would be like (in XML)
<!-- Pre-Seed File for Script Generation -->
<Releases>
<Release>
<Family>F1L</Family>
<ArVersion>3.2.2</ArVersion>
<ReleaseVersion>C3.03.10.001</ReleaseVersion>
<PackageType>FULL</PackageType>
</Release>
<Release>
<Family>F1H</Family>
<ArVersion>4.0.3</ArVersion>
<ReleaseVersion>Ver4.03.20</ReleaseVersion>
<PackageType>SPAL</PackageType>
</Release>
</Releases>
The output should be
F1L 3.2.2 C3.03.10.001 FULL
F1H 4.0.3 Ver4.03.20 SPAL