1

I'm trying to append a new child on a XML file, the problem is that I can't give the appropriate format to the child before inserting it in the XML document.

I Have created the child with minidom.Document() and then appendChild to books.

Do I explained well?

Thanks in advance.

joaquin
  • 82,968
  • 29
  • 138
  • 152
antonio
  • 11
  • 2

1 Answers1

1

Indentation of snippets of XML is a tricky business for XML processors: they are allowed to perform many transformation that you would not expect and they are not allowed to reindent elements in the way you would like without your explicit consent.

Have a look at Pretty printing XML in Python to see how you can indent a full XML document.

Community
  • 1
  • 1
gioele
  • 9,748
  • 5
  • 55
  • 80
  • So I understang is not usefull using xml processor to append new child because it doesn't offer you a really need. What if I just need to indent a few tags in xml file because the rest of the file have the right format?. Thanks giole – antonio Nov 02 '11 at 10:10