Hi, big fan of xpath on .net, and sax in python, but first time using xpath in python.
I have a small script, that uses xpath to select some nodes from a doc, iterates through them, and then ideally uses xpath again to get the relevant data from them. However I can't get that last bit, once I have the xmlNode I cannot get a context from it.
import libxml2
import urllib
doc = libxml2.parseDoc(
urllib.urlopen('http://somemagicwebservice.com/').read())
ctxt = doc.xpathNewContext()
listitems = ctxt.xpathEval('//List/ListItem')
for item in listitems:
itemctxt = item.xpathNewContext()
title = itemctxt.xpathEval('//ItemAttributes/Title')
asin = itemctxt.xpathEval('//Item/ASIN')
itemctxc.xpathFreeContext()
ctxt.xpathFreeContext()
doc.freeDoc()
However the itemctxt = item.xpathNewContext()
bit fails with
itemctxt = item.xpathNewContext()
AttributeError: xmlNode instance has no attribute 'xpathNewContext'
Any ideas how to use xpath on a xmlNode? I can't find any good online info. Thanks