liunx
liunx

Reputation: 761

lxml --pretty_print-- write file problem

I am write a raw data to xml file python program, in my design,we get the raw data line by line, then write it into xml file like:

`<root>\n
  <a> value </a>\n
  <b> value </b>\n
</root>

The first time i write into xml file with pretty_print=True, i got what i want, but when the second time i read the file, get the element root, --add-- new elemnts then save it back with pretty_print=True, but i can not get what i want,it just like:

...\n
<c> value </c></root>

` what's wrong with lxml? Or my fault?

Upvotes: 2

Views: 1675

Answers (1)

Steven
Steven

Reputation: 28696

You might find the answer in the lxml faq: Why doesn't the pretty_print option reformat my XML output?

Upvotes: 3

Related Questions