我使用python2.7、lxml3.7.3和exlst扩展,通过XPath从XML中提取数据。 我可以在测试节点时使用regex扩展,就像lxml documentation 建议的那样。节选:
>>> regexpNS = "http://exslt.org/regular-expressions"
>>> find = etree.XPath("//*[re:test(., '^abc$', 'i')]",
... namespaces={'re':regexpNS})
>>> root = etree.XML("<root><a>aB</a><b>aBc</b></root>")
>>> print(find(root)[0].text)
aBc
我希望使用xpath表达式只生成node text()的子字符串。 我该怎么做?在
要在这里使用xpath表达式,可以
更多示例请参见他们的documentation page。在
相关问题 更多 >
编程相关推荐