[xml] XPath namespace filtering...



I may be confused as to what the XPathContext->namespace struct member
does, but I was under the impression that only nodes whos namespace
was found in XPathContext->namespace would be returned with a given
query.  The use case being something akin to:

doc.find('//root_node/foo/bar', 'other_ns').each do |node|
  puts "node: #{node.path} #{node.namespaces.join(',')}"
end

And I'd get:
Node path: /root_node/foo/bar[1] namespace: other_ns,rn
Node path: /root_node/foo/bar[3] namespace: other_ns,rn
Node path: /root_node/foo/bar[5] namespace: other_ns,rn
Node path: /root_node/foo/bar[7] namespace: other_ns,rn
Node path: /root_node/foo/bar[9] namespace: other_ns,rn

Instead, when I setup XPathContext->namespace with a namespace with
the other_ns prefix, I'm still get all of the results 1-10.  What's
the point of the namespace member?  Is there a better way to do an
XPath query for nodes in the other_ns namespace?  -sc

-- 
Sean Chittenden



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]