【发布时间】:2015-04-05 23:42:56
【问题描述】:
tree.xpath("/exact/path/to/element") 产生[<Element I want>]。
exact/path/to/element 是通过调用tree.getroottree().getpath(element) 获得的。
如果我找到元素的最小 xpath,例如Firebug,tree.xpath("//@minimal-descriptor") 产生 [<Element I want>]。
问题
如何使用 lxml 或其他 Python 库从 element 获取 minimal xpath?
【问题讨论】:
标签: python xpath xml-parsing html-parsing lxml