d33tah
d33tah

Reputation: 11618

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"]')
[]

Why isn't the field returned?

Upvotes: 0

Views: 43

Answers (1)

Shmil The Cat
Shmil The Cat

Reputation: 4668

Simply remove the space in the XPath query b/n field and the bracket [

 t.findall('.//field[@name="tcp.option_len"]')

Upvotes: 2

Related Questions