I am writing a little program right now for my own learning experiences. I have found that I can take the .XSD file at http://www.topografix.com/GPX/1/0/gpx.xsd use the xsd tool in the .NET SDK and generate my .vb file with all the classes created up. I can use this to create an instance of the XMLSeriallizer and use this to read a .gpx file from geocaching.com. However, a lot of the information that I see in the raw XML in the .gpx (e.g. log notes) do not show up in the object that is created.
I found out this is because Speakeasy has extended the gpx.xsd to the definition in cache.xsd found at http://www.Groundspeak.com/cache/1/0/cache.xsd. I tried doing the same process and creating the .vb file with all the classes using the .NET SDK tool xsd and the cache.xsd file. I am able to create up an instance of the XMLSerializer with the classes that are created. However, when I use this to read a .gpx file from geocaching.com, the only properties I see are the geocaching.com specific ones and they all have null values.
1. How do I read in both the standard GPX information as defined in http://www.topografix.com/GPX/1/0/gpx.xsd and the extended information as defined in http://www.Groundspeak.com/cache/1/0/cache.xsd in to the same object when deserilzing a .GPX file from geocaching.com?
2. Why are all the properties coming back null when using just the cache.xsd above? Or does that have to do with knowing how to do 1 above?
Here is some sample code below I am using. Note the cache1_0 namespace is what was generated from the XSD tool pointing toward http://www.Groundspeak.com/cache/1/0/cache.xsd.
Imports System.Xml.Serialization
Imports System.Xml
Public Class frmImport
Dim serializer As XmlSerializer = New XmlSerializer(GetType(GCBetter.cache1_0.cache))
Dim reader As XmlTextReader
Dim gpxfile As GCBetter.cache1_0.cache
Private Sub btnBrowse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBrowse.Click
If OpenFileDialog.ShowDialog().Equals(DialogResult.OK) Then
reader = New XmlTextReader(OpenFileDialog.FileName)
gpxfile = CType(serializer.Deserialize(reader), GCBetter.cache1_0.cache)
‘ Note the gpxfile object has some propties from the cache.xsd description, but they are all Nothing/null
reader.Close()
End If
End Sub
…
End Class