Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: XML Parse

by thargas (Deacon)
on Jun 04, 2015 at 11:09 UTC ( [id://1129046]=note: print w/replies, xml ) Need Help??


in reply to XML Parse

Your key problem is that in the line:

<result xmlns="http://www.test.com/integration/integration">

The xmlns is declaring that everything contained in the result is in that namespace, so there are no, e.g., code_a named elements in the empty namespace, which is what your findnodes call is looking for. They are instead in the http://www.test.com/integration/integration namespace. As choroba notes, you'll have to register that namespace in order to be able to look for elements within it. So you'll need something like:

my $xpc = XML::LibXML::XPathContext->new($doc); $xpc->registerNs('t', 'http://www.test.com/integration/integration'); foreach my $book_node ($xpc->findnodes('/t:books/t:book') ) { say "book name is " .$book_name->findvalue('/t:name'); }

See also XML::LibXML::Node

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2024-04-25 09:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found