in reply to Re: xmlns and XML::LibXML
in thread xmlns and XML::LibXML
The key is that the prefixes used in the XPath expression don't have to have anything to do with the prefixes in the XML file. The following works fine on both your example XML inputs.
my $xml = XML::LibXML->load_xml(string => $txt1); my $xc = XML::LibXML::XPathContext->new($xml); $xc->registerNs('foo', 'DAV:'); print "prop:\n"; print "$_\n" for $xc->findnodes('/foo:propfind/foo:prop'); print "propname:\n"; print "$_\n" for $xc->findnodes('/foo:propfind/foo:propname');
|
|---|