1
我使用lxml來解析包含xi:include元素的文件,並且我正在使用xinclude()解析包含。lxml,xi:include和原始文件
給定一個元素,是否有任何方法來識別該元素最初出現的文件和源代碼行?
例如:
from lxml import etree
doc = etree.parse('file.xml')
doc.xinclude()
xpath_expression = ...
elt = doc.xpath(xpath_expression)
# Print file name and source line of `elt` location