I am trying to replicate some XML code in python to put into a program I am currently working on which does some panoramic captures. At the end the idea is to export an XML file of the capture detail to allow for easier importing into one of the various panorama capture programs.
I am fairly new to Python, but have been using xml.etree.ElementTree, with this I can set information like the root declaration and the header and sub-header but I get a bit lost in two points, the first is how through a sub-element I can set a value (e.g. GPS) and the second is how a sub-element can have multiple values (e.g. mosaic / overlap minimium).
For the elements I had the below working;
root = etree.Element("papywizard")
root.set("version", "c")
header = etree.SubElement(root,"header")
general = etree.SubElement(header, "general")
title = etree.SubElement(general,"title")
I then thought i could do something like title.text("Test123") but this did not work. The full XML I am trying to replicate is below, is someone able to point me in the right direction on how I can set text within a sub-element tag, and beyond that how many tags can be aggregated into one sub-element?
Many Thanks!
<?xml version="1.0" encoding="utf-8"?>
<papywizard version="c">
<header>
<general>
<title>
Test Capture 1
</title>
<gps>
37.8022697,-122.4056749
</gps>
<comment>
Add your comments here
</comment>
</general>
<shooting mode="mosaic">
<headOrientation>
up
</headOrientation>
<cameraOrientation>
landscape
</cameraOrientation>
<stabilizationDelay>
5.0
</stabilizationDelay>
<counter>
001
</counter>
<startTime>
2014-02-23_13h59m01s
</startTime>
<endTime>
2014-02-23_13h53m33s
</endTime>
</shooting>
<camera>
<timeValue>
5.0
</timeValue>
<bracketing nbPicts="1"/>
<sensor coef ="4.74" ratio="4:3"/>
</camera>
<lens type="rectilinear">
<focal>
12.7
</focal>
</lens>
<mosaic>
<nbPicts pitch="5" yaw="10"/>
<overlap minimum="0.25" pitch="0.25" yaw="0.25"/>
</mosaic>
</header>
<shoot>
<pict bracket="1" id="1">
<time>
2014-02-23_13h59m01s
</time>
<position pitch="37.96" roll="0.0" yaw="-99.96"/>
</pict>
<pict bracket="1" id="2">
<time>
2014-02-23_13h59m01s
</time>
<position pitch="18.98" roll="0.0" yaw="-99.96"/>
</pict>
<pict bracket="1" id="3">
<time>
2014-02-23_13h59m01s
</time>
<position pitch="0.00" roll="0.0" yaw="-99.96"/>
</pict>
</shoot>
</papywizard>