[lxml-dev] Processing instruction roundtrip (again)

Christian Zagrodnick cz at gocept.com
Mon Dec 10 09:33:06 CET 2007


On 08.12.2007, at 16:17, Stefan Behnel wrote:

>
> Christian Zagrodnick wrote:
>>>>> obj = lxml.objectify.XML('<a/><?foo:bar blurb ?>')
>>>>> lxml.etree.tostring(obj)
>> '<a/>'
>
> You are requesting a serialisation of the Element, so that's the  
> expected result.
>
> This should work:
>
>    etree.tostring(etree.ElementTree(obj))
>
> or:
>
>    etree.tostring(obj.getroottree())

Ah yes. This way it works. Rather strange that fromstring/tostring is  
not symetric. But from the usesage patterns it probably makes sense.  
I'm probably going to serialse the roottree whenever a node doesn't  
have a parent.

But thanks for the hint :)

-- 
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