I have been asked to do some work on some GPX files: these files originate from 
GPS devices, and are in XML format. I've never had to deal with XML before, so 
I have been trying to learn how to do so from the LC user manual - from about 
page 189.  There is a sample XML file and a discussion of the various 'revXML' 
functions which are on offer. There are a few typos, but it doesn't **look** 
hard.
(I don't have any other source of information since my crazy ISP has cut off my 
internet connection, and I am confined at present to emails sent & received via 
a friend.)

So far, so good: however, although I can create an XML tree and retrieve the 
Root Node as per the documentation, I can't make any of the other functions 
work on my data. I hope someone can explain the fundamentals of what I'm doing 
wrong.

My GPX file begins like this:

<?xml version="1.0" encoding="UTF-8"?>
<gpx xmlns="http://www.topografix.com/GPX/1/1"; creator="Geolives" 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";>
  <metadata />
  <trk>
    <trkseg>
      <trkpt lat="42.78981" lon="1.336446">
        <ele>750.5912</ele>
      </trkpt>
      <trkpt lat="42.78981" lon="1.336446">
        <ele>750.5912</ele>
      </trkpt>
[etc etc etc]

The file seems to be well-formed, apart from the fact that the first child node 
is found by revXML to be "gpx/metadata", and I can't see the closure for the 
metadata tag at the other end of the document. In fact the document ends 
</gpx>f I try to stick in </metadata> before this last line, the LC function 
refuses to form the table, so the original file must be right. I don't 
understand this.

Anyway, revXMLRootNode returns "gpx" (without the quotes)

and revXMLFirstChild returns "/gpx/metadata"

but after that nothing works. However closely I follow the example in the 
manual, I can't get the revXMLContents or revXMLNodeContents functions to 
return anything. For example (among many attempts), 
revXMLNodeContents(1,"/gpx/metadata/trk/trkseg") returns

"xmlerr, can't find element"

I feel like I've tried everything, but it seems there's something basic I 
haven't grasped. XML seems like a simple idea, but in practice it's dreadfully 
easy to slip up.

TIA for any advice, as long as it doesn't mean significant downloading.

Graham


Sent from my iPad
_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to