2

I've got problem with minidom. My code is:

from lxml import etree as ET
from xml.dom import minidom

xml_string = ET.tostring(self.model)

reparsed = minidom.parseString(xml_string)        
text = reparsed.toprettyxml(indent="   ")

I'm expecting (and when I try to print xml_string ,there is right argument order)

<def id="A" set="normal"/>

but minidom does changes to:

<def set="normal" id="A"/>

This is lxml tree code

temp = ET.SubElement(self.model,"def")
temp.set("id", A)
temp.set("set", "normal")
Alexandre Neukirchen
  • 2,713
  • 7
  • 26
  • 36
Qunts
  • 41
  • 1
  • 4
  • 2
    Related : [Preserve order of attributes when modifying with minidom](http://stackoverflow.com/questions/662624/preserve-order-of-attributes-when-modifying-with-minidom) – har07 Apr 19 '16 at 11:35
  • But i need minidom for indent spaces – Qunts Apr 19 '16 at 13:04

0 Answers0