public async void readClimateAnomaly(ObservableCollection <Model> ocm) { var contents = await ReadFileContentsAsync("climateanomaly.xml"); //Debug.WriteLine(contents); XDocument extractedContents = XDocument.Parse(contents); foreach (var childElem in extractedContents.Descendants().Where(p => p.Name.LocalName == "data")) { string childName = childElem.Element("year").Value; string childValue = childElem.Element("value").Value; //Debug.WriteLine(childName+","+childValue); try { Sparrow.Chart.DoublePoint pi = new Sparrow.Chart.DoublePoint(); double d = double.Parse(childName, System.Globalization.NumberStyles.AllowLeadingSign); double v; if (childValue.Contains('-')) { v = double.Parse(childValue.Replace("-", "")); v *= -1; } else { v = double.Parse(childValue); } //Debug.WriteLine(childName+", "+childValue); pi.Data = d; pi.Value = v; ocm.Add(new Model(d, v)); } catch (Exception e) { Debug.WriteLine(e); } } }
public async void readClimateAnomaly(ObservableCollection<Model> ocm) { var contents = await ReadFileContentsAsync("climateanomaly.xml"); //Debug.WriteLine(contents); XDocument extractedContents = XDocument.Parse(contents); foreach (var childElem in extractedContents.Descendants().Where(p => p.Name.LocalName == "data")) { string childName = childElem.Element("year").Value; string childValue = childElem.Element("value").Value; //Debug.WriteLine(childName+","+childValue); try { Sparrow.Chart.DoublePoint pi = new Sparrow.Chart.DoublePoint(); double d=double.Parse(childName, System.Globalization.NumberStyles.AllowLeadingSign); double v; if (childValue.Contains('-')) { v = double.Parse(childValue.Replace("-", "")); v *= -1; } else { v = double.Parse(childValue); } //Debug.WriteLine(childName+", "+childValue); pi.Data = d; pi.Value = v; ocm.Add(new Model(d, v)); } catch (Exception e) { Debug.WriteLine(e); } } }