Stéphane Peillon wrote:
Hello,
I try to carry out a request xpath on the return of a preceding request
(selectNodeList) but the result is not that awaited: it would seem that
the context is not taken into account in the second request. I always
obtain the same result independently of the context.
I join an example of file xml and an extract of the source code.
Can you explain me where is located my error? I acknowledge more not to
understand…
Thank you
Stephane
This is the xml file :
...
This is my code :
...
const string xEvolZone = "/racine/[EMAIL PROTECTED]'z1']/noeud2";
XPathEvaluator theEvaluator;
...
// lecture de la valeur
const string xValParam = "//[EMAIL PROTECTED]'val2']/@attr2";
XalanNode* valeur = theEvaluator.selectSingleNode(*theDOMSupport, noeud,
XalanDOMString(xValParam.c_str()).c_str(), *thePrefixResolver);
In both cases, your XPath expressions are absolute, not relative, since
they both begin with "/". In the case of an absolute path, the context
node is ignored.
You probably want a relative XPath expression, like this:
".//[EMAIL PROTECTED]'val2']/@attr2"
Note the "." which indicates the location path begins with the context node.
Finally, from the structure of your document, it seems to me you don't need
to use "//", which can be expensive, depending on the depth of the
document. Instead, you could just use:
"[EMAIL PROTECTED]'val2']/@attr2"
which is also a relative location path.
Dave