[lxml-dev] lxml.etree.parse doesn't take parser argument into account?
Christian Zagrodnick
cz at gocept.com
Mon Jun 11 20:52:04 CEST 2007
On 2007-06-11 16:29:51 +0200, Stefan Behnel <stefan_ml at behnel.de> said:
> Hi,
>
> Christian Zagrodnick wrote:
>> maybe I'm doning something very wrong here. Regarding the following:
>>
>> In [1]:import StringIO
>>
>> In [2]:import lxml.etree
>>
>> In [3]:import lxml.objectify
>>
>> In [4]:parser = lxml.etree.XMLParser()
>>
>> In
>> [5]:parser.setElementClassLookup(lxml.objectify.ObjectifyElementClassLookup())
In
[6]:lxml.etree.parse(StringIO.StringIO("<a/>"),
>>
>> parser)
>> Out[6]:<etree._ElementTree object at 0x1450e40>
>>
>>
>> I would have expected to get an objectified element out of the parse
>> call. What am I missing here? Or is this a bug?
>
> As your example shows, parse() returns an ElementTree object, not an Element.
>
> http://effbot.org/zone/element.htm#reading-and-writing-xml-files
>
> If you want the root Element object, call the "getroot()" method on the result
> tree.
gaah... *takes blindfold off*
Thanks Stefan.
--
Christian Zagrodnick
gocept gmbh & co. kg · forsterstrasse 29 · 06112 halle/saale
www.gocept.com · fon. +49 345 12298894 · fax. +49 345 12298891
More information about the lxml-dev
mailing list