ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

XML Parsing problem (with XML Object)

COW Forums : Adobe After Effects

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Tomasz Tejchman
XML Parsing problem (with XML Object)
on Jul 16, 2012 at 10:35:17 am

Hi there!

I need to parse GPX data to create a new composition. It's actually just a XML file with GPS data.



Here is an example how I create XML object:

var myFile = File.openDialog("Choose GPX file","*.*");


function readXMLFile(file) {
if (!file.exists) {
throw "Cannot find file: " + deodeURI(file.absoluteURI);
}
file.encoding = "UTF8";
file.lineFeed = "unix";
file.open("r", "TEXT", "????");
var str = file.read();
file.close();
return new XML(str);
};

var ch = readXMLFile(myFile);


ch return whole XML file and it's OK. Unfortunately when I try to retrieve a children nodes it returns nothing.

Below is my XML file.

<?xml version="1.0" encoding="UTF-8"?>
<gpx version="v1.1.5" creator="Move! Bike Computer" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.topografix.com/GPX/1/1" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd http://www.topografix.com/GPX/gpx_overlay/0/3 http://www.topografix.com/GPX/gpx_overlay/0/3/gpx_overlay.xsd http://www.topografix.com/GPX/gpx_modified/0/1 http://www.topografix.com/GPX/gpx_modified/0/1/gpx_modified.xsd">
<trk>
<name>
No name
</name>
<trkseg>
<trkpt lat="52.23674" lon="20.893658">
<ele>
145.0
</ele>
<time>
2012-07-11T20:49:22Z
</time>
<speed>
0
</speed>
</trkpt>
<trkpt lat="52.23675" lon="20.893658">
<ele>
145.0
</ele>
<time>
2012-07-11T20:49:23Z
</time>
<speed>
0
</speed>
</trkpt>
<trkpt lat="52.23675" lon="20.893658">
<ele>
145.0
</ele>
<time>
2012-07-11T20:49:24Z
</time>
<speed>
0
</speed>
</trkpt>
<trkpt lat="52.23676" lon="20.893658">
<ele>
145.0
</ele>
<time>
2012-07-11T20:49:25Z
</time>
<speed>
0
</speed>
</trkpt>
</trkseg>
</trk>
</gpx>


I found there is an elements() function but it works strange.


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]