ich hätte da mal ein Frage zur lxml-lib und dem Binden des space-Attributes an den xml-namespace.
Angenommen ich hätte ein XML-Fragement, wie nachfolgend beschrieben mit einem space-Attribut.
Code: Alles auswählen
>> xml = "<root xml:space=\"preserve\"/>"
>> root = etree.fromstring(xml)
>> print etree.tostring(root)
<root xml:space="preserve"/>
Nun kann es ja vorkommnen, dass ich so ein Attribut mit entsprechendem Namespace selbst an ein neues Element setzen will, doch wie mache ich das ?
Weiß da jemand Rat?
Code: Alles auswählen
>> root = etree.Element("root", space="preserve")
>> print etree.tostring(root)
<root space="preserve"/>