Feature #1290

Updated by Brecht De Man over 10 years ago

For nice viewing of the output XML files, some whitespace/indentation is in order. Recent versions of Safari display XML quite nicely, any other text editor I'm using displays everything as a single line. Shouldn't be very hard.

I've got this much in Python to do the same thing (mostly pseudocode) before I realised I'm suppose to write a PhD. And also it would make more sense if the JavaScript just generated it properly from the start.

@#!/usr/bin/python@ #!/usr/bin/python

@import os@ import os

@ # get every XML file in folder@ folder
@for for file in os.listdir("."): # You have to put this script in folder where output XML files are.@
@
are.
if file.endswith(".xml"):@
@
file.endswith(".xml"):
# read in each line as single string@
@
string
# for each line:@
@
line:
# at every '<...>'@
@
&#x27;&lt;...&gt;&#x27;
# increase variable 'indentation'@
@
&#x27;indentation&#x27;
# enter new line afterwards [if immediately '<' afterwards, or in other words except if next one is corresponding </ ...>]@
@
...&gt;]
# at every '</...>'@
@
&#x27;&lt;/...&gt;&#x27;
# decrease variable 'indentation'@
@
&#x27;indentation&#x27;
# enter new line afterwards@
@
afterwards
# at every '<... />'@
@
/&gt;&#x27;
# enter new line afterwards@

(Sorry indentation is not showing in preview)
afterwards

Back