Python tool for download gpx from sequences

Thanks for the update Danilo,
I can now open it with Mapsource, so the structure is now a valid xml file.
But there is still one problem. It makes one big gpx track, so it connects the last point of the first file with the first point of the second file. This creates one big mess of straight lines.
Better is:

  <trk>
    <name>track 1</name>
    <trkseg>
      <trkpt lat="xx.x" lon="y.yy"/>
      <trkpt lat="xx.x" lon="y.yy"/>
    </trkseg>
  </trk>

  <trk>
    <name>track 2</name>
    <trkseg>
      <trkpt lat="xx.x" lon="y.yy"/>
      <trkpt lat="xx.x" lon="y.yy"/>
    </trkseg>
  </trk>

I have done some search and replace with

<trkseg> to <trk><trkseg> and </trkseg> to </trkseg></trk>

which works for me!