资 源 简 介
py-dom-xpath is a pure Python implementation of XPath 1.0. It supports almost all XPath 1.0, with the main exception being the namespace axis. It operates on DOM 2.0 nodes, and works well with xml.dom.minidom.
py-dom-xpath requires Python 2.5 or greater.
Simple queries are easy:
>>> xpath.find("//item", doc)[, ]
Namespaces are fully supported (although the namespace axis is not):
>>> context = xpath.XPathContext()>>> context.namespaces["py"] = "http://python.example.org/">>> context.findvalues("//py:skit/@name", doc)[u"argument", u"lumberjack", u"parrot"]
XPath variables are also supported:
>>> xpath.find("//chapter[@name = $name]", doc, name="Python")[]
py-dom-xpath uses