Does ElementTree's Parent XPath actually work?

J

Jason Cooper

I'm curious to know if anyone with ElementTree 1.3 has gotten the parent XPath to work? According to http://effbot.org/zone/element-xpath.htm, you should be able to do
'1.3.0'
...

but that always return None for me. Has anyone else seen this particular XPath work? Am I just doing something wrong?

Thanks for you help!
Jason

PS. In case you're wondering, yes I know that lxml supports parent points and, yes, I'm aware of http://effbot.org/zone/element.htm#accessing-parents. I'm really wondering if the mentioned XPath is broken or something.
 
J

Jason Cooper

I'm curious to know if anyone with ElementTree 1.3 has gotten the parent XPath to work? According to http://effbot.org/zone/element-xpath.htm, you should be able to do


but that always return None for me. Has anyone else seen this particular XPath work? Am I just doing something wrong?

Thanks for you help!
Jason

PS. In case you're wondering, yes I know that lxml supports parent pointsand, yes, I'm aware of http://effbot.org/zone/element.htm#accessing-parents. I'm really wondering if the mentioned XPath is broken or something.

Looks like I may have figured out my own answer. I just noticed that using '..' when searching on the tree (as opposed to the element) works as expected. Makes sense after I stepped back and recalled that the elements don't contain pointers to their parents. The tree, on the other hand, can see all.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,585
Members
45,080
Latest member
mikkipirss

Latest Threads

Top