[Tutor] Basic ElementTree - another question

Phil phillor9 at gmail.com
Mon Feb 24 19:54:07 EST 2020


On 24/2/20 6:30 pm, Peter Otten wrote:

I thought that I would now be able to proceed to the next step but 
unfortunately that's not the case despite extensive Internet searching.

This is what I want to achieve:

   <wpt lat="-32.506533000" lon="137.740017000">
     <name>1</name>
     <cmt>1</cmt>
     <desc>1</desc>
   </wpt>

and then repeat as above to the next destination, with a different name.

This gives me the first line but, of course, the next line is not correct.

   gpx = ET.Element("gpx")

   wpt = ET.SubElement(gpx, "wpt", lat="-32.506533000", lon= 
"137.740017000")
   ET.SubElement(wpt, "name=1")

I've found all sorts of examples but nothing specific to my current needs.

-- 
Regards,
Phil



More information about the Tutor mailing list