.net silverlight中的Kml解析问题

.net silverlight中的Kml解析问题,.net,.net,我试图将一个kml文件解析为xml,以获取silverlight中的坐标。 但是它没有以特定的格式解析,因为根元素与每个元素重复。 请建议任何更好的方式,因为我是silverlight的新手 OpenFileDialog openDiag = new OpenFileDialog(); if ((bool)openDiag.ShowDialog()) { StreamReader reader = new StreamReader(openDiag.File.OpenRead()); w

我试图将一个kml文件解析为xml,以获取silverlight中的坐标。 但是它没有以特定的格式解析,因为根元素与每个元素重复。 请建议任何更好的方式,因为我是silverlight的新手

OpenFileDialog openDiag = new OpenFileDialog();
if ((bool)openDiag.ShowDialog())
{
  StreamReader reader = new StreamReader(openDiag.File.OpenRead());
  while (!reader.EndOfStream)
  {
     str = reader.ReadToEnd();
  }
  reader.Close();
  XDocument xdoc = XDocument.Parse(str);
  IEnumerable<POI> list = from p in xdoc.Descendants("Placemark")
                          select new POI
                          {
                            accountID = MainPage.CurrentAccount,
                            Name = (string)p.Element("name").Value,
                            Lat1 = decimal.Parse((string)p.Element("latitude").Value),
                            Long1 = Parse((string)p.Element("longitude").Value),
                          };
OpenFileDialog openDiag=新建OpenFileDialog();
if((bool)openDiag.ShowDialog())
{
StreamReader=新的StreamReader(openDiag.File.OpenRead());
而(!reader.EndOfStream)
{
str=reader.ReadToEnd();
}
reader.Close();
XDocument xdoc=XDocument.Parse(str);
IEnumerable list=来自xdoc.substands(“Placemark”)中的p
选择新POI
{
accountID=MainPage.CurrentAccount,
Name=(字符串)p.Element(“Name”).Value,
Lat1=decimal.Parse((字符串)p.Element(“纬度”).Value),
Long1=解析((字符串)p.Element(“经度”).Value),
};