omegaweaponZ has asked for the wisdom of the Perl Monks concerning the following question:
UPDATE: This has been resolved. Thanks @choroba
I have an issue when trying to parse out child nodes from an XML using XPath Context. I can get attributes fine but it seems to have issues drilling down to grab the child nodes. Can someone explain why? Here's an example:<parent_node xmlns="my_context"> <wrapper att1="abc"> <childnodeA>stuff</childnodeA> </wrapper> <wrapper att1="abcd"> <childnodeA>stuff2</childnodeA> </wrapper> </parent_node>
$xpath = XML::LibXML::XPathContext->new($xml->documentElement); $xpath->registerNs('x', 'my_context'); foreach $key($xpath->findnodes('x:wrapper')) { $att1 = $key->getAttribute('att1'); $childnodeA = $key->findnodes('./childnodeA'); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: XML::LibXML::XPathContext and Child Nodes
by choroba (Cardinal) on Aug 27, 2014 at 13:15 UTC | |
by omegaweaponZ (Beadle) on Aug 27, 2014 at 13:20 UTC |