in reply to Re^2: XML::LibXML drives me to drinking
in thread XML::LibXML drives me to drinking
My node had pretty good clues, actually. :P Try this–
use strict; use XML::LibXML; my $string = <<""; <?xml version="1.0"?> <ItemLookupResponse xmlns="http://webservices.amazon.com/AWSECommerceS +ervice/2013-08-01"> <Items> <Item> <ASIN>B01KI4JSQY</ASIN> </Item> </Items> </ItemLookupResponse> my $doc = XML::LibXML->new->load_xml(string => $string, {no_blanks => +1}); my $xc = XML::LibXML::XPathContext->new($doc); $xc->registerNs( x => $doc->getDocumentElement->namespaceURI ); for my $item ( $xc->findnodes('//x:ItemLookupResponse/x:Items/x:Item') + ) { print $item->firstChild->nodeName, "\n"; print $item->firstChild->toString, "\n"; print $xc->findvalue('x:ASIN', $item), "\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: XML::LibXML drives me to drinking
by tunafish (Beadle) on Oct 23, 2016 at 04:40 UTC |