Why can't I use LINQ to get the XML elements in WinRT?

DannyMW

New Member
1.What I want
get proper xml elements out of a xml fileThe XML\[code\]<?xml version="1.0" encoding="utf-8" standalone="yes"?><tasks> <task> <title>Test0001</title> <due>06/17/2012</due> </task> <task> <title>Test0002</title> <due>06/17/2012</due> </task> <task> <title>Test0003</title> <due>06/17/2012</due> </task><tasks>\[/code\]2.what I codeThe Linq block:\[code\] StorageFile file1 = await ApplicationData.Current.LocalFolder.GetFileAsync("BetterTask.xml"); XDocument doc1 = new XDocument(); using (var ReadStream1 = await file1.OpenStreamForReadAsync() as Stream) { doc1 = XDocument.Load(ReadStream1); } var data = http://stackoverflow.com/questions/11070075/from query in doc1.Descendants("task") select new mytask { title = (string)query.Element("title"), due = (string)query.Element("due") }; List<mytask> myTasks = data.ToList(); myTodayListBox.ItemsSource = myTasks;\[/code\]the mytask Class\[code\]public class mytask{ public string title { get; set; } public string due { get; set; }}\[/code\]3.What I get
I set a break at the last of the block, when the app break, i found in the LinQ part:
<1>the [doc1] is full of the XML content
<2>but [myTasks] is empty(count = 0),....4. Why and how to solve
:(
 
Back
Top