Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^3: XML::LibXML drives me to drinking

by Your Mother (Archbishop)
on Oct 23, 2016 at 03:40 UTC ( [id://1174534]=note: print w/replies, xml ) Need Help??


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
    And LIKE THAT, it all clicks into place for me. THANK YOU!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1174534]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2024-04-20 00:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found