[Tutor] Basic ElementTree xml question

Phil phillor9 at gmail.com
Sun Feb 23 20:32:32 EST 2020


Thank you for reading this,

I'm trying to create an xml file with an output that looks like this"

<gpx>

   <wpt lat="-32.506533000" lon="137.740017000">

and this is the closest that I have so far achieved:

<gpx>

   <wpt>

with this code snippet:

from xml.etree import ElementTree as ET

gpx = ET.Element("gpx")

wpt = ET.SubElement(gpx, "wpt")

So my question is, how to I include the lat and lon text after <wpt ?

I've searched the Internet for example code but haven't found anything 
that allows strings after "<wpt ". So far, I haven't been able to turn 
the information in the Etree manual into anything close to what I need.

-- 
Regards,
Phil



More information about the Tutor mailing list