Sami Islam wrote:
How to use Xpath from Xalan.
Hello,
I need some clarification on how to
correctly use the XPathEvaluator in Xalan.
In the sample programs from Xalan 1.7
the evaluator is first used :
1) to find the context node.
2) to find the list of nodes.
3) finally evaluate the result.
My questions:
1) Do I have to get a context node?
e.g. If I want the node at
/doc/[EMAIL PROTECTED]'Tom']/@last do I have to first get the context node
for "/" and then evaluate the _expression_ "doc/[EMAIL PROTECTED]'Tom']/@last?
Isn't there a way I can just obtain
the node directly without the 1) step.
e.g. evaluator.selectSingleNode(...,
..., XalanDOMString("/doc/[EMAIL PROTECTED]'tom')/@last").c_str( ), ...);
instead of evaluator.selectSingleNode(..., ...,
XalanDOMString("/").c_str( ), ...); first.
Sami,
You can use as a context node the documentElement node. For
instance:
XalanElement* context = xalanDocument->getDocumentElement();
evaluator.selectSingleNode(domSupport,
context, XalanDOMString("/doc/[EMAIL PROTECTED]'tom'])/@last").c_str( ),
...);
---------------------------------------
Francesc Guim Bernat
http://francesc.guim.net --
The only thing that is unclear to me
is the evaluator.evaluate( ) member function that takes a
"context_node" as its second parameter and "XpathString" as its third.
Regards,
Sami
|