weismat has asked for the wisdom of the Perl Monks concerning the following question:
I am trying to use XML::LibXML with an XPath query.
I have created the query using Sketchpath (http://pgfearo.googlepages.com/) which allows to create XPath queries on the fly. (I have used it mainly with C# before).
I use the following code for trying to query the document according to a turorial on perlmonks.
This fails as no nodes are found. When manually walking through the tree I see that the namespace using $doc->firstChild->nameSpaceURI. How do I add the found name space, so that the XPATH query gives the wanted result - I guess that Sketchpath handles this automatically. The XML look like this <?xml version="1.0" encoding ="UTF-8"?><xxx xmlns="http://xxx><yyy>zzz</yyy></xxx> The query is a simple /xxx/yyy (sorry - missed this when simplyfying the xml.my $parser=XML::LibXML->new(); my $doc=$parser->parse_file($file); foreach my $node($doc->findnodes($xpathQuery));
Back to
Seekers of Perl Wisdom