我有以下 XML:
<!ENTITY abbr "abbreviation">
<pos>&abbr;</pos>
我想获得pos
节点的“未触及”内部 XML 内容(即&abbr;
)
以下方法不起作用:
parser = etree.XMLParser(resolve_entities=False)
doc = etree.parse(inFile, parser)
print doc.find("pos").text # ! this prints "None"
print etree.tostring(doc.find("pos")) # ! this prints "<pos>&abbr;</pos>"
doc = etree.parse(inputFile)
print doc.find("pos").text # ! this prints "abbreviation"
任何简单的解决方案?