Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > irrXML
Processing EXN_TEXT

Willem
Guest
Quote
2010-03-07 04:24:42

I am trying to get GPS data out of a GPX file:

The problem is the elevation <ele>value</ele>, which is EXN_TEXT. Here is a part of the .xml file:


<trkpt lat="-41.337876" lon="174.790258">
<ele>102.04</ele>
<time>2009-12-13T23:57:13Z</time>
<extensions>
<gpxtpx:TrackPointExtension>
<gpxtpx:atemp>10.4</gpxtpx:atemp>
</gpxtpx:TrackPointExtension>
</extensions>
</trkpt>


Any ideas, this works, but is ugly:



unsigned char processNext = 0;
std::string lat, lon, ele;
IrrXMLReader* xml = createIrrXMLReader("data/adelaide.gpx");

while (xml && xml->read()) {
std::string e = xml->getNodeName();

if (!strcmp("ele", e.c_str())) {
processNext++;
}

switch (xml->getNodeType()) {
case EXN_NONE:
break;
case EXN_COMMENT:
break;
case EXN_ELEMENT_END:
break;
case EXN_UNKNOWN:
break;
case EXN_CDATA:
break;
case EXN_ELEMENT:
if (!strcmp("trkpt", xml->getNodeName())) {
lat = xml->getAttributeValue("lat");
lon = xml->getAttributeValue("lon");
printf("%s,%s,", lat.c_str(), lon.c_str());
}
break;
case EXN_TEXT:
// The next element should be <ele>
if (processNext == 1) {
ele = xml->getNodeData();
printf("%s\n", ele.c_str());
} else if (processNext == 2) {
processNext = 0;
}
break;
}
}

delete xml;



I would like to do something on the <ele>value</ele> node but don't know what else to do.

Any suggestions would be appreciated.

Thanks,
Willem
source code



Willem
Guest
Quote
2010-03-07 04:34:26

Just to add to the above, the actual problem is that there are other EXN_TEXT nodes, such as <time>value</time> and I don't know how to tell the EXN_TEXT nodes apart, so I need something like the EXN_ELEMENT getNodeName() for the EXN_TEXT nodes. Is this possible?

Thanks
Willem


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Internat?onal" (you are not logged in)


Text:

 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


   






Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact