Problem with newlines when I use toprettyxml()

前端 未结 8 867
不知归路
不知归路 2020-11-28 15:17

I\'m currently using the toprettyxml() function of the xml.dom module in a Python script and I\'m having some trouble with the newlines. If don\'t

8条回答
  •  北海茫月
    2020-11-28 15:40

    toprettyxml() is quite awful. It is not a matter of Windows and '\r\n'. Trying any string as the newlparameter shows that too many lines are being added. Not only that, but other blanks (that may cause you problems when a machine reads the xml) are also added.

    Some workarounds available at
    http://ronrothman.com/public/leftbraned/xml-dom-minidom-toprettyxml-and-silly-whitespace

提交回复
热议问题