
April 28, 2009
5:15 a.m.
Hi, David Gardner wrote:
Ran into something that maybe a bug, or at least isn't clear from the documentation [http://codespeak.net/lxml/api/lxml.etree-module.html#fromstring] because it doesn't mention a return type for etree.fromstring(). I had expected it to behave similar to etree.parse().
Yes, that's a common misconception. Let's see if this works better: https://codespeak.net/viewvc/lxml/trunk/src/lxml/lxml.etree.pyx?r1=63185&r2=64752 The reason for this difference is that fromstring()/XML() is often used for XML fragments, where returning an ElementTree wouldn't make sense. Stefan