Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl use warnings; use strict; my $a = do {local $/; <DATA>}; use XML::XPath; use XML::XPath::XMLParser; my $xp = XML::XPath->new(xml => $a); my $nodeset = $xp->findnodes('/OPEN/Info/Other/Id'); foreach my $cid ($xp->findnodes('/OPEN/more/Info/Other')) { my $id = $cid->find('Id'); print "**$id**\n"; } __DATA__ <?xml version="1.0" encoding="ISO-8859-1"?> <OPEN> <more> <Info> <Other> <Type>Key</Type> <Id>CONVERSE1</Id> </Other> <Other> <Type>Number</Type> <Id>1</Id> </Other> <Other> <Type>Sum</Type> <Id/> </Other> <Other> <Type>LN</Type> <Id>WXY12345678</Id> </Other> </Info> </more> <more> <Info> <Other> <Type>Key</Type> <Id>CONVERSE2</Id> </Other> <Other> <Type>Number</Type> <Id>11</Id> </Other> <Other> <Type>Sum</Type> <Id/> </Other> <Other> <Type>LN</Type> <Id>12345678XZW</Id> </Other> </Info> </more> </OPEN>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Reaching Nodes Help with XML::XPath
by ikegami (Patriarch) on May 12, 2010 at 19:24 UTC | |
by Anonymous Monk on May 12, 2010 at 19:35 UTC | |
by ikegami (Patriarch) on May 12, 2010 at 19:39 UTC | |
by Anonymous Monk on May 13, 2010 at 12:14 UTC | |
by ikegami (Patriarch) on May 13, 2010 at 16:29 UTC |