EDN Admin
Well-known member
I have to parse a file with the following content (stripped to focus) based on the
http://www.topografix.com/GPX/1/0 GPX namespace:
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; <<span style="color:#A31515; gpx<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; trk<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; name<span style="color:Blue; >trk1<span style="color:Blue; </<span style="color:#A31515; trk<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; trkseg<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; trkpt<span style="color:Blue; ><span style="color:Blue; <<span style="color:#A31515; name<span style="color:Blue; >n1<span style="color:Blue; </<span style="color:#A31515; name<span style="color:Blue; ><span style="color:Blue; </<span style="color:#A31515; trkpt<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; trkpt<span style="color:Blue; ><span style="color:Blue; <<span style="color:#A31515; name<span style="color:Blue; >n2<span style="color:Blue; </<span style="color:#A31515; name<span style="color:Blue; ><span style="color:Blue; </<span style="color:#A31515; trkpt<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; trkseg<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; trk<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; trk<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; name<span style="color:Blue; >trk2<span style="color:Blue; </<span style="color:#A31515; trk<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; trkseg<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; trkpt<span style="color:Blue; ><span style="color:Blue; <<span style="color:#A31515; name<span style="color:Blue; >n3<span style="color:Blue; </<span style="color:#A31515; name<span style="color:Blue; ><span style="color:Blue; </<span style="color:#A31515; trkpt<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; trkpt<span style="color:Blue; ><span style="color:Blue; <<span style="color:#A31515; name<span style="color:Blue; >n4<span style="color:Blue; </<span style="color:#A31515; name<span style="color:Blue; ><span style="color:Blue; </<span style="color:#A31515; trkpt<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; trkseg<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; trk<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; gpx<span style="color:Blue; >
[/code]
When I now run a linq-query on doc.Descendants(ns + "trkpt") I iterate through
all track-points getting the list "n1, n2, n3, n4" What I need tho, are two lists, both containing their tracks: "n1, n2" and "n3, n4" Since its a bit late to use WHERE or the like in the linq itself, I guess I have to split both tracks
out first, then feedining the separate parts to individual linqs. Unfortunately I have no idea so far, how to achieve this.
Thanx very much in advance for any pointers.<br/>
//Carsten
View the full article
http://www.topografix.com/GPX/1/0 GPX namespace:
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; <<span style="color:#A31515; gpx<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; trk<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; name<span style="color:Blue; >trk1<span style="color:Blue; </<span style="color:#A31515; trk<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; trkseg<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; trkpt<span style="color:Blue; ><span style="color:Blue; <<span style="color:#A31515; name<span style="color:Blue; >n1<span style="color:Blue; </<span style="color:#A31515; name<span style="color:Blue; ><span style="color:Blue; </<span style="color:#A31515; trkpt<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; trkpt<span style="color:Blue; ><span style="color:Blue; <<span style="color:#A31515; name<span style="color:Blue; >n2<span style="color:Blue; </<span style="color:#A31515; name<span style="color:Blue; ><span style="color:Blue; </<span style="color:#A31515; trkpt<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; trkseg<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; trk<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; trk<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; name<span style="color:Blue; >trk2<span style="color:Blue; </<span style="color:#A31515; trk<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; trkseg<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; trkpt<span style="color:Blue; ><span style="color:Blue; <<span style="color:#A31515; name<span style="color:Blue; >n3<span style="color:Blue; </<span style="color:#A31515; name<span style="color:Blue; ><span style="color:Blue; </<span style="color:#A31515; trkpt<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; trkpt<span style="color:Blue; ><span style="color:Blue; <<span style="color:#A31515; name<span style="color:Blue; >n4<span style="color:Blue; </<span style="color:#A31515; name<span style="color:Blue; ><span style="color:Blue; </<span style="color:#A31515; trkpt<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; trkseg<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; trk<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; gpx<span style="color:Blue; >
[/code]
When I now run a linq-query on doc.Descendants(ns + "trkpt") I iterate through
all track-points getting the list "n1, n2, n3, n4" What I need tho, are two lists, both containing their tracks: "n1, n2" and "n3, n4" Since its a bit late to use WHERE or the like in the linq itself, I guess I have to split both tracks
out first, then feedining the separate parts to individual linqs. Unfortunately I have no idea so far, how to achieve this.
Thanx very much in advance for any pointers.<br/>
//Carsten
View the full article