[lxml-dev] eetree.fromsring() returns Element, expected ElementTree

Stefan Behnel stefan_ml at behnel.de
Tue Apr 28 07:15:27 CEST 2009


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


More information about the lxml-dev mailing list