Wait, are you saying I need to create a new XML::LibXML::XPathContext object for each node as I loop through them?!
I modified my code in the following way:
# Parse items foreach my $item ($xml->findnodes('/x:ItemLookupResponse/x:Items/x:Ite +m', $parser)){ my $item_xml = XML::LibXML::XPathContext->new($item); $item_xml->registerNs('x', 'http://webservices.amazon.com/AWSE +CommerceService/2013-08-01'); print $item_xml->findvalue('x:ASIN'), "\n"; print $item_xml->findnodes('x:ASIN')->shift->textContent, "\n" +; }
And bingo!
B01KI4JSQY B01KI4JSQY
Oy vey! Wouldn't it be much more convenient if a XML::LibXML::XPathContext object calling the findnodes() method returned another XML::LibXML::XPathContext object, rather than a XML::LibXML::Node or XML::LibXML::Element object?
I haven't pulled this much hair in one day for a coding-related reason IN YEARS.
In reply to Re^2: XML::LibXML drives me to drinking
by tunafish
in thread XML::LibXML drives me to drinking
by tunafish
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |