aboutsummaryrefslogtreecommitdiff
path: root/Tools/px4params/xmlout.py
diff options
context:
space:
mode:
authorAnton Babushkin <anton.babushkin@me.com>2014-03-30 00:25:26 +0400
committerAnton Babushkin <anton.babushkin@me.com>2014-03-30 00:25:26 +0400
commitd2553bfd2930eb02664d564559fa361b80c63f61 (patch)
tree21cda568519c33a261edaaa9c370cc9ba9c7f466 /Tools/px4params/xmlout.py
parent0789189c0588ebebd24a523f9639411be89c6a9b (diff)
parent9b1de5004c673ebe8bdf68f1b518565cccd6b05b (diff)
downloadpx4-firmware-d2553bfd2930eb02664d564559fa361b80c63f61.tar.gz
px4-firmware-d2553bfd2930eb02664d564559fa361b80c63f61.tar.bz2
px4-firmware-d2553bfd2930eb02664d564559fa361b80c63f61.zip
Merge branch 'master' into offboard2
Diffstat (limited to 'Tools/px4params/xmlout.py')
-rw-r--r--Tools/px4params/xmlout.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/Tools/px4params/xmlout.py b/Tools/px4params/xmlout.py
new file mode 100644
index 000000000..e845cd1b1
--- /dev/null
+++ b/Tools/px4params/xmlout.py
@@ -0,0 +1,26 @@
+from xml.dom.minidom import getDOMImplementation
+import codecs
+
+class XMLOutput():
+ def __init__(self, groups):
+ impl = getDOMImplementation()
+ xml_document = impl.createDocument(None, "parameters", None)
+ xml_parameters = xml_document.documentElement
+ for group in groups:
+ xml_group = xml_document.createElement("group")
+ xml_group.setAttribute("name", group.GetName())
+ xml_parameters.appendChild(xml_group)
+ for param in group.GetParams():
+ xml_param = xml_document.createElement("parameter")
+ xml_group.appendChild(xml_param)
+ for code in param.GetFieldCodes():
+ value = param.GetFieldValue(code)
+ xml_field = xml_document.createElement(code)
+ xml_param.appendChild(xml_field)
+ xml_value = xml_document.createTextNode(value)
+ xml_field.appendChild(xml_value)
+ self.xml_document = xml_document
+
+ def Save(self, filename):
+ with codecs.open(filename, 'w', 'utf-8') as f:
+ self.xml_document.writexml(f, indent=" ", addindent=" ", newl="\n")