diff options
Diffstat (limited to 'releng/toolkit/xmlutils.py')
-rwxr-xr-x | releng/toolkit/xmlutils.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/releng/toolkit/xmlutils.py b/releng/toolkit/xmlutils.py new file mode 100755 index 00000000000..cb206f4e57e --- /dev/null +++ b/releng/toolkit/xmlutils.py @@ -0,0 +1,32 @@ +################################################################################
+# Copyright (c) 2014 CEA LIST.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# Laurent Wouters laurent.wouters@cea.fr - Initial API and implementation
+#
+################################################################################
+
+# System imports
+import xml.dom.minidom # Minimal XML
+
+
+# encoding of the XML files
+XML_ENCODING="UTF-8"
+# identation string
+XML_IDENT="\t"
+# new line string
+XML_NEWLINE="\n"
+
+
+# Outputs the XML document in the given file with pretty printing
+def output(document, file):
+ document.normalize()
+ content = XML_NEWLINE.join([line for line in document.toprettyxml(XML_IDENT, XML_NEWLINE, XML_ENCODING).split(XML_NEWLINE) if line.strip()])
+ output = open(file, "w")
+ output.write(content)
+ output.close()
\ No newline at end of file |