开发者

lxml --pretty_print-- write file problem

开发者 https://www.devze.com 2023-01-30 10:04 出处:网络
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:

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?

0

精彩评论

暂无评论...
验证码 换一张
取 消