in reply to Searching subtrees with XML::LibXML::XPathContext always searches whole document - why?

I haven't checked thoroughly your code, but I'd be willing to bet that the problem is that //apps:login should be .//apps:login. With the . you start from the current node, without it you start from the root of the document. That's a common mistake with XPath. Am I right?

  • Comment on Re: Searching subtrees with XML::LibXML::XPathContext always searches whole document - why?
  • Select or Download Code

Replies are listed 'Best First'.
Re^2: Searching subtrees with XML::LibXML::XPathContext always searches whole document - why?
by ikegami (Patriarch) on Feb 08, 2010 at 16:47 UTC
    Indeed.
    //apps:login

    is short for

    /descendant::apps:login

    Just like with directory paths, expressions starting with "/" start searching at the root. To look for descendants of the topic node, one must use a relative path such as

    descendant::apps:login
    or
    .//apps:login
      Thank you both!!! Knew it had to be something stupid-simple that was wrong with my usage.