我正在尝试分析 xml 数据,但在使用时遇到了关于 HTML 实体的问题
import xml.etree.ElementTree as ET
tree = ET.parse(my_xml_file)
root = tree.getroot()
for regex_rule in root.findall('.//regex_rule'):
print(regex_rule.get('input')) #this ".get()" method turns < into <, but I want to get < as written
print(regex_rule.get('input') == "(?<!\S)hello(?!\S)") #prints out false because ElementTree's get method turns < into < , is that right?
这是xml文件内容:
<rules>
<regex_rule input="(?<!\S)hello(?!\S)" output="world"/>
</rules>
如果有人可以指导我从输入的 xml 属性中获取字符串,而不进行转换,我将不胜感激
<
进入
<