Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy can't I use LINQ to get the XML elements in WinRT?
    primarykey
    data
    text
    <p><strong>1.What I want</strong><br/> get proper xml elements out of a xml file</p> <p><strong>The XML</strong></p> <pre><code>&lt;?xml version="1.0" encoding="utf-8" standalone="yes"?&gt; &lt;tasks&gt; &lt;task&gt; &lt;title&gt;Test0001&lt;/title&gt; &lt;due&gt;06/17/2012&lt;/due&gt; &lt;/task&gt; &lt;task&gt; &lt;title&gt;Test0002&lt;/title&gt; &lt;due&gt;06/17/2012&lt;/due&gt; &lt;/task&gt; &lt;task&gt; &lt;title&gt;Test0003&lt;/title&gt; &lt;due&gt;06/17/2012&lt;/due&gt; &lt;/task&gt; &lt;tasks&gt; </code></pre> <p><strong>2.what I code</strong></p> <p>The Linq block:</p> <pre><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 = from query in doc1.Descendants("task") select new mytask { title = (string)query.Element("title"), due = (string)query.Element("due") }; List&lt;mytask&gt; myTasks = data.ToList(); myTodayListBox.ItemsSource = myTasks; </code></pre> <p>the mytask Class</p> <pre><code>public class mytask { public string title { get; set; } public string due { get; set; } } </code></pre> <p><strong>3.What I get</strong><br/> I set a break at the last of the block, when the app break, i found in the LinQ part:<br/> &lt;1>the [doc1] is full of the XML content<br/> &lt;2>but [myTasks] is empty(count = 0),....</p> <p><strong>4. Why and how to solve</strong><br/> :(</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload