XML-Document generation by Automagic

Post your questions and help other users.

Moderator: Martin

Post Reply
dominik4545
Posts: 3
Joined: 01 Jul 2016 12:12

XML-Document generation by Automagic

Post by dominik4545 » 22 Jul 2016 09:19

Hello everyone,

I want to create a flow which writes my current location to a file. To do so, I saw there is already an existing solution how to save location information: GPX-files, which are based on XML (see: https://en.wikipedia.org/wiki/GPS_Exchange_Format).

So I want to know, if there is a good solution how to generate XML-files using automagic? As far as I know there is only a way to append information to a file, but this would not work for XML-files.

Thanks a lot in advance!

Best regards
Dominik

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: XML-Document generation by Automagic

Post by Martin » 23 Jul 2016 09:15

Hi,

You could either store the locations in a global list and write the XML only on demand or you could append the XML fragments without "closing" the XML and then copy the XML to another file and close it:

The flow would first write following "header" to temp_gpx.xml:

Code: Select all

<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<gpx xmlns="http://www.topografix.com/GPX/1/1" xmlns:gpxx="http://www.garmin.com/xmlschemas/GpxExtensions/v3" xmlns:gpxtpx="http://www.garmin.com/xmlschemas/TrackPointExtension/v1" creator="Oregon 400t" version="1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd http://www.garmin.com/xmlschemas/GpxExtensions/v3 http://www.garmin.com/xmlschemas/GpxExtensionsv3.xsd http://www.garmin.com/xmlschemas/TrackPointExtension/v1 http://www.garmin.com/xmlschemas/TrackPointExtensionv1.xsd">
  <metadata>
    <link href="http://www.garmin.com">
      <text>Garmin International</text>
    </link>
    <time>2009-10-17T22:58:43Z</time>
  </metadata>
  <trk>
    <name>Example GPX Document</name>
    <trkseg>
an action would then append such an XML fragment to the file for each location:

Code: Select all

      <trkpt lat="47.644548" lon="-122.326897">
        <ele>4.46</ele>
        <time>2009-10-17T18:37:26Z</time>
      </trkpt>
then use an action Copy File: temp_gpx.xml to final_gpx.xml to copy the file and append following text to properly close the XML:

Code: Select all

    </trkseg>
  </trk>
</gpx>

Regards,
Martin

dominik4545
Posts: 3
Joined: 01 Jul 2016 12:12

Re: XML-Document generation by Automagic

Post by dominik4545 » 23 Jul 2016 16:18

Hi Martin,

thanks for that solution! I will try it like this :)

Best regards
Dominik

Post Reply