[xml] Re: Is it possible to do XPath queries in subtrees?



Stefan Seefeld <seefeld sympatico ca>:

Steinar Bang wrote:

Since the only function that create an xmlXPathContext is
xmlPathNewContext() which takes xmlDoc argument, does this means
that it's only possible to do XPath queries from the top of
documents?

Here is my how I implement a 'Node::Find' method (warning: C++ ahead !)
[snip! example]
i.e. I explicitely set the 'node' member of the context variable
after it has been allocated.

OK.  That verifies that it should work.  What had confused me in my
first attempts on my own, was that I thought the top of the search
would be the current node, which made me try queries such as "//id",
and "/customer/id".

But queries starting with "/" always goes to the top of the document,
it seems.  When I set the node, and tried queries like "id", it worked
perfectly.

Thanx!


- Steinar




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