XML ElementTree Parse.

marc.wyburn at googlemail.com marc.wyburn at googlemail.com
Thu Oct 12 07:02:23 EDT 2006


Thanks Fredrik, thats got me started but just incase anyone looks there
is a slight mistype in your code...

 or you could do something like
>
>     for dir_elem in tree.findall("dirob"):
>         for file_elem in dirob.findall("fileob"):
>             print file_elem.findtext("filesize")
>
> to loop over all directory objects at the top level, and print the sizes for
> all files in those directories.

should read

>>> for delem in tree.findall("dirob"):
... 	for felem in delem.findall("fileob"):
... 		print felem.findtext("filesize")
... 		
933888
9365




More information about the Python-list mailing list