Python XpathEvaluator without namespace
问题 I need to write a dynamic function that finds elements on a subtree of an ATOM xml document. To do so, I've written something like this: tree = etree.parse(xmlFileUrl) e = etree.XPathEvaluator(tree, namespaces={'def':'http://www.w3.org/2005/Atom'}) entries = e('//def:entry') for entry in entries: mypath = tree.getpath(entry) + "/category" category = e(mypath) The code above fails to find category. The reason is that getpath returns an XPath without namespaces, whereas the XPathEvaluator e()