xml.etree.ElementTree findall() 未按预期运行
xml.etree.ElementTree findall() not behaving as expected
>>> import xml.etree.ElementTree as ET
>>> t = ET.fromstring('<root><field name="tcp.option_len" ></field></root>')
>>> t.findall('.//field [@name="tcp.option_len"]')
[]
为什么 field
没有返回?
只需删除 XPath 查询 b/n 字段中的 space 和括号 [
t.findall('.//field[@name="tcp.option_len"]')
>>> import xml.etree.ElementTree as ET
>>> t = ET.fromstring('<root><field name="tcp.option_len" ></field></root>')
>>> t.findall('.//field [@name="tcp.option_len"]')
[]
为什么 field
没有返回?
只需删除 XPath 查询 b/n 字段中的 space 和括号 [
t.findall('.//field[@name="tcp.option_len"]')