[Tutor] Basic ElementTree - another question
Phil
phillor9 at gmail.com
Thu Feb 27 00:59:12 EST 2020
On 27/2/20 11:44 am, Don Jennings wrote:
> The lack of success can take many forms. I encourage you to paste:
> - code which you have tried
> - the full traceback of any errors
OK Don, thank you for your patience. This is what I need the file to
look like:
<gpx>
<wpt lat="-32.506533000" lon="137.740017000">
<name>1</name>
</wpt>
</gpx>
and this is what I've currently got:
<gpx>
<wpt lat="-32.506533000" lon="137.740017000" />
<name name="1" />
</gpx>
This is the code that generates the above file:
from xml.etree import ElementTree as ET
gpx = ET.Element("gpx")
wpt = ET.SubElement(gpx, "wpt", lat="-32.506533000", lon=
"137.740017000")
name = ET.SubElement(gpx, "name", name="1")
There aren't any syntax errors in the code, only logic errors. The logic
errors generate the wpt block ending symbol at the end of the first
line and the name entry is completely wrong.
The pasted code is just a sample of what I've tried. I've attempted to
adapt every piece of example code that I can find but without success.
Getting lat and lon on the same line, without the block closing symbol,
has been the source of the problem.
--
Regards,
Phil
More information about the Tutor
mailing list