Python xml ElementTree findall returns empty result -


i parse following xml file using python xml elementtree api.

<?xml version="1.0" encoding="utf-8" standalone="yes"?>  <foos>  <foo_table>  <!-- bar --> <fooelem>  <fname>bbbb</fname>  <group>somegroup</group>  <module>some module</module> </fooelem>  <fooelem>  <fname>aaaa</fname>  <group>other group</group>  <module>other module</module> </fooelem> <!-- bar -->  </foo_table> </foos> 

in example code try find elements under /foos/foo_table/fooelem/fname findall doesn't find when running code.

import xml.etree.celementtree et tree = et.elementtree(file="min.xml") in tree.findall("./foos/foo_table/fooelem/fname"):      print  root = tree.getroot() in root.findall("./foos/foo_table/fooelem/fname"):      print 

i not experienced elementtree api, i've used example under https://docs.python.org/2/library/xml.etree.elementtree.html#example. why not working in case?

foos root, need start findall below, e.g.

root = tree.getroot() in root.findall("foo_table/fooelem/fname"):      print i.text 

output:

bbbb aaaa 

Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - jQuery UI Splitter/Resizable for unlimited amount of columns -

javascript - IE9 error '$'is not defined -