D
David Veeneman
I've used the XmlDocument class for some time to parse XML documents. After
being away from it for a while, I have come across a type of XML file it
doesn't seem to work with, although the XML seems perfectly valid. I'm
hoping someone in this forum can point out the flaw in my logic that I know
must be causing the problem.
Here's the code that I'm using to parse the XML:
XmlDocument xmlDocument = new XmlDocument();
xmlDocument.Load(@"D:\DCV Documents\Visual Studio
2005\Projects\GeoTagger\TestGpx\HHV House.gpx");
XmlNode root = xmlDocument.DocumentElement;
XmlNode wptNode = root.SelectSingleNode("wpt");
The root node parses correctly, but wptNode is null, even after the call to
SelectSingleNode(). What am I doing wrong?
Here is the XML markup that I am trying to parse:
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<gpx xmlns="http://www.topografix.com/GPX/1/1" creator="MapSource 6.12.4"
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>
<link href="http://www.garmin.com">
<text>Garmin International</text>
</link>
<time>2007-09-29T02:21:05Z</time>
<bounds maxlat="40.2492361" maxlon="-105.8391159"
minlat="40.2492361" minlon="-105.8391159" />
</metadata>
<wpt lat="40.2492361" lon="-105.8391159">
<ele>2603.1157227</ele>
<name>TestLocation</name>
<cmt>22-SEP-07 12:33:08AM</cmt>
<desc>22-SEP-07 12:33:08AM</desc>
<sym>Trail Head</sym>
</wpt>
</gpx>
Thanks in advance for your help!
being away from it for a while, I have come across a type of XML file it
doesn't seem to work with, although the XML seems perfectly valid. I'm
hoping someone in this forum can point out the flaw in my logic that I know
must be causing the problem.
Here's the code that I'm using to parse the XML:
XmlDocument xmlDocument = new XmlDocument();
xmlDocument.Load(@"D:\DCV Documents\Visual Studio
2005\Projects\GeoTagger\TestGpx\HHV House.gpx");
XmlNode root = xmlDocument.DocumentElement;
XmlNode wptNode = root.SelectSingleNode("wpt");
The root node parses correctly, but wptNode is null, even after the call to
SelectSingleNode(). What am I doing wrong?
Here is the XML markup that I am trying to parse:
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<gpx xmlns="http://www.topografix.com/GPX/1/1" creator="MapSource 6.12.4"
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>
<link href="http://www.garmin.com">
<text>Garmin International</text>
</link>
<time>2007-09-29T02:21:05Z</time>
<bounds maxlat="40.2492361" maxlon="-105.8391159"
minlat="40.2492361" minlon="-105.8391159" />
</metadata>
<wpt lat="40.2492361" lon="-105.8391159">
<ele>2603.1157227</ele>
<name>TestLocation</name>
<cmt>22-SEP-07 12:33:08AM</cmt>
<desc>22-SEP-07 12:33:08AM</desc>
<sym>Trail Head</sym>
</wpt>
</gpx>
Thanks in advance for your help!