in reply to XML::Simple usage question
Congratulations! You've completed the first level! Are you ready to play level two? XML::LibXML.
You appear to have outgrown the facilities that XML::Simple offers. You may wish to read Stepping up from XML::Simple to XML::LibXML.
use 5.010; use XML::LibXML 1.94; my $xml = XML::LibXML->load_xml(IO =>\*DATA); foreach my $element ($xml->findnodes("/a/*")) { say "Got ", $element->tagName; if ($element->tagName eq 'b') { say " type is ", $element->{type}; } } __DATA__ <a> <b type="1"/> <b type="2"/> <c/> <b type="3"/> </a>
Output is...
Got b type is 1 Got b type is 2 Got c Got b type is 3
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: XML::Simple usage question
by gri6507 (Deacon) on Jul 13, 2012 at 21:26 UTC |