EDN Admin
Well-known member
Hi
I would like to write a module that will read .gpx files (heres xml schema: http://www.topografix.com/GPX/1/1/) I would like to use xml serializer, but Im stucked right here...
I wrote this:
Imports System.IO<br/>
Imports System.Xml<br/>
Imports System.Xml.Serialization<br/>
<br/>
Module Module1<br/>
Sub Main()<br/>
Dim XmlFile As FileStream = New FileStream("C:SOFTWAREfoxboro.gpx", FileMode.Open) <- HERE I GET ERROR<br/>
Dim gpx As gpxType<br/>
Dim Serializer As XmlSerializer = New XmlSerializer(GetType(gpxType))<br/>
Try<br/>
gpx = CType(Serializer.Deserialize(XmlFile), gpxType)<br/>
Catch ex As Exception<br/>
Console.WriteLine("Not valid > gpx v.1.1")<br/>
Exit Sub<br/>
End Try<br/>
End Sub<br/>
End Module
<Serializable()> Public Class gpxType<br/>
Public version As String <br/>
Public creator As String<br/>
Public metadata As metadataType<br/>
Public wpt() As wptType<br/>
Public rte() As rteType<br/>
Public trk() As trkType<br/>
Public extensions As extensionsType<br/>
End Class
Public Class rteType<br/>
.... other stuff
Could you tell me pls what am I doing wrong?
Thanks
Tom
View the full article
I would like to write a module that will read .gpx files (heres xml schema: http://www.topografix.com/GPX/1/1/) I would like to use xml serializer, but Im stucked right here...
I wrote this:
Imports System.IO<br/>
Imports System.Xml<br/>
Imports System.Xml.Serialization<br/>
<br/>
Module Module1<br/>
Sub Main()<br/>
Dim XmlFile As FileStream = New FileStream("C:SOFTWAREfoxboro.gpx", FileMode.Open) <- HERE I GET ERROR<br/>
Dim gpx As gpxType<br/>
Dim Serializer As XmlSerializer = New XmlSerializer(GetType(gpxType))<br/>
Try<br/>
gpx = CType(Serializer.Deserialize(XmlFile), gpxType)<br/>
Catch ex As Exception<br/>
Console.WriteLine("Not valid > gpx v.1.1")<br/>
Exit Sub<br/>
End Try<br/>
End Sub<br/>
End Module
<Serializable()> Public Class gpxType<br/>
Public version As String <br/>
Public creator As String<br/>
Public metadata As metadataType<br/>
Public wpt() As wptType<br/>
Public rte() As rteType<br/>
Public trk() As trkType<br/>
Public extensions As extensionsType<br/>
End Class
Public Class rteType<br/>
.... other stuff
Could you tell me pls what am I doing wrong?
Thanks
Tom
View the full article