7 Oct
2009
7 Oct
'09
10:45 a.m.
If I run the code: test = etree.XML('<root><a/>text</root>') for x in test.iter(): print("%s - %s"%(x.tag, x.text)) I get the output: root - None a - None I expected that root.text would have been 'text' rather than none. However, if I flip the text and <a/> tag, then it works. E.g. test = etree.XML('<root>text<a/></root>') for x in test.iter(): print("%s - %s"%(x.tag, x.text)) Output: root - text a - None Anyone know why this is, or how to work around it? Thanks! - Clif