XML::XPath query
Hi List,
I doing XML for the first path and got the things as
I wanted using XPath. However only one thing I cannot
figure out is how do I get Telephone number in a separate
list. What the module returning to me is concatenated list
of Telephone number and I have to add extra delimiter " " (space)
in my case. I do split on space and then reconstruct list out
of it.
Is there a way that this module will return me the list instead
of single object in concatenated form.
Thanks and Regards,
Manish
Here is my code.
-----------------------------------------
#!/usr/bin/perl -w
use strict;
use XML::XPath;
my $xml = qq(
<Instructions>
<Agent>
<Contacts>
<Contact>
<TelephoneNumbers>
<TelephoneNumber
Type="Mobile"> 777777</TelephoneNumber>
<TelephoneNumber
Type="Home"> 88888</TelephoneNumber>
<TelephoneNumber
Type="Work"> 99999</TelephoneNumber>
</TelephoneNumbers>
</Contact>
</Contacts>
<Address/>
<TelephoneNumbers>
<TelephoneNumber> 1111111</TelephoneNumber>
<TelephoneNumber> 2222222</TelephoneNumber>
</TelephoneNumbers>
</Agent>
</Instructions>
);
my $doc = XML::XPath-> new(xml=>$xml);
my @agents = $doc-> findnodes('//Agent');
foreach my $agent (@agents) {
print $agent-> findvalue('TelephoneNumbers/TelephoneNumber'), "\n";
}
-----------------------------------------
.