I have a bit of script that I think is nearly there. I have worked out a crude way of writing it, but I can't work out how to get it to function as a for loop.
I am extracting data from an xml file that uses the following format:
<Trackpoint>
<Time>2012-01-17T11:44:35Z</Time>
<Position>
<LatitudeDegrees>51.920211518183351</LatitudeDegrees>
<LongitudeDegrees>26.706042898818851</LongitudeDegrees>
</Position>
<AltitudeMeters>-43.6026611328125</AltitudeMeters>
</Trackpoint>
<Trackpoint>
<Time>2012-01-17T11:45:21Z</Time>
<Position>
<LatitudeDegrees>51.920243117958307</LatitudeDegrees>
<LongitudeDegrees>26.706140967085958</LongitudeDegrees>
</Position>
<AltitudeMeters>-43.6026611328125</AltitudeMeters>
</Trackpoint>
I can use the following to get say the LatitudeDegrees:
from xml.dom.minidom import parse
doc = parse('/Users/name/Documents/GPS/gps.tcx')
lat = doc.getElementsByTagName("LatitudeDegrees")
time = doc.getElementsByTagName("Time")
trackpoint = doc.getElementsByTagName("Trackpoint")
for x in lat:
print(x.firstChild.data)
but I would like to get the Lat, Long and time in order.
I am guessing I need to use
for x in trackpoint
but the only way I can work out how to do that is as follows.
count = 0
n = len(trackpoint)
while count < n:
print(time[count].firstChild.data)
print(lat[count].firstChild.data)
print(lon[count].firstChild.data)
count += 1
anyone have any ideas? I think I am just missing something really simple!