python - xml.etree.ElementTree findall() not behaving as expected -


>>> import xml.etree.elementtree et >>> t = et.fromstring('<root><field name="tcp.option_len" ></field></root>') >>> t.findall('.//field [@name="tcp.option_len"]') [] 

why isn't field returned?

simply remove space in xpath query b/n field , bracket [

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

Comments

Popular posts from this blog

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -

javascript - Restarting Supervisor and effect on FlaskSocketIO -

php - Mongodb connectivity error -