I am currently parsing an XML file to get a coordinate value using the below code.
private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
{
WebClient busStops = new WebClient();
busStops.DownloadStringCompleted += new DownloadStringCompletedEventHandler(busStops_DownloadStringCompleted);
busStops.DownloadStringAsync(new Uri("http://www.location.com/file.xml"));
}
void busStops_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
if (e.Error != null)
return;
var busStopInfo = XDocument.Load("Content/BusStops2.xml");
var Transitresults = from root in busStopInfo.Descendants("Placemark")
let StoplocationE1 = root.Element("Point").Element("coordinates")
let nameE1 = root.Element("name")
select new TansitVariables
{
Stoplocation = StoplocationE1 == null ? null : StoplocationE1.Value,
name = nameE1 == null ? null : nameE1.Value,
};
listBox2.ItemsSource = Transitresults;
}
public class TansitVariables
{
public string Stoplocation { get; set; }
public string name { get; set; }
}
}
}
the value is in the String StopLocation, but I would like to convert this to 3 values Lat, Long and Alt.
I haven’t used String Split before and the documentation doesn’t explain how I can do this from a parsed output.
Out is this 174.732224,-36.931053,0.000000
thanks in advance.
Given this output string, you can get your three numbers via:
Edit:
The portion of your code that would require changing is likely: