in reply to Re: XML: Simple - nested XML data
in thread XML: Simple - nested XML data

I think that should've been XML::XPath ... which I inherited from for my XML::Tidy module. You might try:

#!/usr/bin/perl use strict; use warnings; use XML::XPath; my $xpob = XML::XPath->new('xml' => '<SuperItem> <UserID>1234</UserID> <MajorItems> <MinorItem> <Item>Box</Item> </MinorItem> </MajorItems> <MajorItems> <MinorItem> <Item>Suitcase</Item> </MinorItem> </MajorItems> </SuperItem>'); my @itmz = $xpob->findnodes('//Item'); # retn nodez in doc ordr print $itmz[1]->getChildNode(1)->getValue(); # XPath indices are 1-bas +ed # ... so the abov line takes the 2nd <Item /> elem (Bcuz Perl is 0-bas +ed) # && traverses down to its 1st child-node (this time no more nested el +emz # but just a TextNode as the only child) to print that value: "Suitcas +e"

XPath is good shit. Just today, I used it in a COLLADA file with: '//node[@type="JOINT"]' to give me all the elements that describe animation bones for a Wii game I'm working on. Tim sure is Toady. ;) Have fun!

-Pip@CPAN.Org
PipForPresident.Org