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>\开发者_如何学Pythonn
<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?
You might find the answer in the lxml faq: Why doesn't the pretty_print option reformat my XML output?
精彩评论