[lxml-dev] How to set an attribute with a xml-namepace
Grimm, Markus
Grimm at juris.de
Tue Apr 28 16:11:33 CEST 2009
thanks to Holger and Stefan,
I didn't wangle the intellectual transfer from element to attribute as described in
http://codespeak.net/lxml/tutorial.html#the-e-factory :-)
Thanks,
Markus
Hi,
> >> xml = "<root xml:space=\"preserve\"/>"
> >> root = etree.fromstring(xml)
> >> print etree.tostring(root)
> <root xml:space="preserve"/>
>
> everything fine, and now...
>
> >> root = etree.Element("root", space="preserve")
> >> print etree.tostring(root)
> <root space="preserve"/>
>>> root = etree.Element("root", attrib={'{http://www.w3.org/XML/1998/namespace}space': 'preserve'})
>>> print etree.tostring(root)
<root xml:space="preserve"/>
>>>
Cheers,
Holger
--
Psssst! Schon vom neuen GMX MultiMessenger gehört? Der kann`s mit allen: http://www.gmx.net/de/go/multimessenger01
More information about the lxml-dev
mailing list