[lxml-dev] Processing instruction roundtrip (again)

Stefan Behnel stefan_ml at behnel.de
Sat Dec 8 16:17:11 CET 2007


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

Stefan


More information about the lxml-dev mailing list