I am trying to extract the value of two particular attributes from an XML file, whose structure is below;
<environment>
<applications>
<application1>
<app-config>
<server host="boxA" port="1234"/>
</app-config>
</applicaitons>
</environment>
I want to be able to read the value of the attribute "host" and "port".
I've tried with the foillowing piece of code but this doesn't work for me.
#!/usr/local/bin/perl -w
use XML::XPath;
my $file = "configuration.xml";
my $xp = XML::XPath->new(filename => $file);
my $hname = $xp->find('/environment/applications/application1/app-config/server/@host');
my $pnumber = $xp->find('/environment/applications/application1/app-config/server/@port');
print $hname;
But this does not return any output whatsoever when I run this command.
Thanks in advance