Script for parsing:<?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>
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)#!/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);
How can I get the value of the Description property?XML Version is: 1.0 Document encoding is: UTF-16 Description: Description:
In reply to LibXML: Can't get value of attribute using DOM by timtowtdi
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |