In it I register 'D' as a prefix for 'DAV:' and so using a XPath with 'D' as prefix works where the XML uses it too.
No, the expression /D:propfind/D:propname works on both $txt1 and $txt2.
Your sub testfn does not give you enough information. If $dom->findnodes($xpath) blows up, the second "test case" $xc->findnodes($xpath) never gets executed.
/DAV:propfind/DAV:propname will not work because you have not registered a prefix "DAV" with the XPathContext.
/propfind/propname will not work because that expression seeks nodes without a namespace, but the nodes in your document have a namespace.
$dom->findnodes($xpath) will not always work because it lacks the power that XPathContext provides.
Please also reference your previous thread xmlns and XML::LibXML, a lot has already been discussed there.
There is further documentation in XML::LibXML::Node under findnodes, in XML::LibXML::XPathContext, and actually plenty of good information on the net in general: xpath namespace.
In reply to Re: Using XPaths with XML::LibXML and XPathContext
by Anonymous Monk
in thread Using XPaths with XML::LibXML and XPathContext
by worik
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |