1

Suppose I want to edit a node in xml and edit one of its attributes. I want to be able to do a simple file diff to just see one row changed. Dumping the xml using prettyprint changes the whole xml structure.

sms169
  • 143
  • 2
  • 8

2 Answers2

1

Well then don't use prettyprint.

In xml.dom.minidom for example, if you do

doc = xml.dom.minidom.parse(inputfile)
do_something_with(doc)
outputfile.write(doc.toxml("utf-8").decode("utf-8"))

all the structure/whitespace etc. will remain unchanged.

Tim Pietzcker
  • 328,213
  • 58
  • 503
  • 561
0

Consider NOT using "a simple file diff". See this SO question.

Community
  • 1
  • 1
John Machin
  • 81,303
  • 11
  • 141
  • 189