[XML-SIG] [XML-checkins]Evaluate on nodes
jeremy.kloth at fourthought.com
Thu Jan 12 00:21:14 CET 2006
On Wednesday 11 January 2006 16:10, Vladimir Blagojevic wrote:
> I am new to PyXml and I am struggling with xpath evaluation. Namely,
> if I pass a node to the Evaluate function instead of the whole
> document, I would expect the xpath evaluation to start from that node,
> not from its containing document.
> Let me illustrate my problem with an example:
> doc =
>ble>') print len(xpath.Evaluate('//tr', doc.documentElement))
> td = xpath.Evaluate('//td', doc.documentElement)
> print len(xpath.Evaluate('//tr', td))
> I would expect 1, since the td element only contains onew descendant
> tr element.
> If one looks at the code of ParsedAbbreviatedAbsoluteLocationPath.py,
> we see why:
> root = context.node.ownerDocument or context.node
> I would expect this to read:
> root = context.node or context.node.ownerDocument
If you change your expression to read ".//tr", an
AbbreviatedRelativeLocationPath, you should get the result you are expecting.
More information about the XML-SIG