xm.Initialize
DateTime.DateFormat = "yyyy-MM-dd"
Private Zoffset= DateTime.GetTimeZoneOffsetAt(DateTime.Now) As Int
DateTime.SetTimeZone(0)
Dim x As XMLBuilder
x = x.create("gpx")
x.namespace($"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.topografix.com/GPX/1/1" xmlns:gpxdata="http://www.cluetrust.com/XML/GPXDATA/1/0" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd http://www.cluetrust.com/XML/GPXDATA/1/0 http://www.cluetrust.com/Schemas/gpxdata10.xsd" version="1.1" creator="http://ridewithgps.com/">"$)
x = x.element("metadata").element("name").text("test gpx").up() _
.element("link").attribute("href","https://ridewithgps.com/trips/55290156") _
.element("text").text("test gpx").up().up()
x=x.element("time").text("2020-08-30T07:23:37Z").up().up()
x = x.element("trk")
x=x.element("name").text("test gpx").up()
x=x.element("trkseg")
Private timestart=DateTime.now As Long
For tx=0 To 57
Private lat=47.05471420288086 +0.1*Cos(tx/57) As Float
Private lon=1.458349347114563 +0.1*Sin(tx/57) As Float
Private alt=Rnd(800,1000) As Float
Private hr=Rnd(60,70) As Int
Private cd=Rnd(50,60) As Int
timestart=timestart+tx*1000
'
Private timestring=DateTime.Date(timestart)&"T"&DateTime.time(timestart)&"Z" As String
x=x.element("trkpt").attribute("lat", NumberFormat(lat,2,7)).attribute("lon", NumberFormat(lon,3,7))
x=x.element("ele").text(NumberFormat(alt/10,1,5)).up()
x=x.element("time").text(timestring).up()
x=x.element("extentions")
x=x.element("gpxdata:hr").text(hr).up()
x=x.element("gpxdata:cadence").text(cd).up().up().up()
'
Next
Dim props As Map
props.Initialize
props.Put("{http://xml.apache.org/xslt}indent-amount", "4")
props.Put("indent", "yes")
Private q As String
q=(x.asString2(props))
Private sf As StringFunctions
sf.Initialize
Private l As List
l.Initialize
l=sf.Split(q,CRLF)
For xx=0 To l.Size-1
Log(l.Get(xx))
Next