Hi Monks,
I have an XML-file 'imgfile.xml' and I would like to get the values of Hight, Width and Description. I am basically capable of getting all values of all tags, but not when they are formed like in this XML-file:
<?xml version="1.0" encoding="UTF-16" standalone="yes"?>
<imgfile IMGFileVersion="1.2.0.2312">
<images>
<views>
<view type="contacts_view">
<nodes>
<node>
<properties>
<property type="Hight">434</property>
<property type="Width">2346</property>
<property type="Description">Smile</proper
+ty>
</properties>
</node>
<node>
<properties>
<property type="Hight">1024</property>
<property type="Width">768</property>
<property type="Description">Background.jp
+eg</property>
</properties>
</node>
</nodes>
</view>
</views>
</images>
</imgfile>
Script for parsing:
#!/usr/bin/perl
use 5.010;
use strict;
use warnings;
use XML::LibXML;
#my $FILENAME = ('imgfile.xml');
my $parser = XML::LibXML->new;
my $dom = XML::LibXML->load_xml(
location => 'imgfile.xml'
);
print 'XML Version is: ', $dom->version, "\n";
print 'Document encoding is: ', $dom->encoding, "\n";
foreach my $image ($dom->findnodes('imgfile/images/views/view/nodes/no
+de/properties')) {
say 'Description: ', $image->findvalue('./Description');
}
exit(0);
I am trying to parse it with the perlscript above, but as you may probably understand, it only returns:
(For the example I only try to get the Description-value)
XML Version is: 1.0
Document encoding is: UTF-16
Description:
Description:
How can I get the value of the Description property?
The great mistake is to anticipate the outcome of the engagement; Let nature take its course, and your tools will strike at the right moment.