Note that there are some explanatory texts on larger screens.

plurals
  1. PODeserialize XML in a WP8 Application
    primarykey
    data
    text
    <p>I'm trying to develop a Windows phone 8 app (I'm new in wp8 dev).</p> <p>I have an XML file that look like this:</p> <hr> <pre><code>&lt;?xml version="1.0" ?&gt; &lt;root&gt; &lt;quotes&gt; &lt;quote&gt; &lt;author&gt;&lt;/author&gt; &lt;text&gt;&lt;/text&gt; &lt;text&gt;&lt;/text&gt; &lt;text&gt;&lt;/text&gt; &lt;/quote&gt; &lt;/quotes&gt; &lt;/root&gt; </code></pre> <hr> <p>This is my Quotes class:</p> <pre><code>[XmlRoot("root")] public class Quotes { [XmlArray("quotes")] [XmlArrayItem("quote")] public ObservableCollection&lt;Quote&gt; Collection { get; set; } } </code></pre> <hr> <p>This is the quote class:</p> <pre><code>public class Quote { [XmlElement("author")] public string author { get; set; } [XmlElement("text")] public string text { get; set; } } </code></pre> <hr> <p>Then I use this code to deserialize it:</p> <pre><code>XmlSerializer serializer = new XmlSerializer(typeof(Quotes)); XDocument document = XDocument.Parse(e.Result); Quotes quotes = (Quotes) serializer.Deserialize(document.CreateReader()); quotesList.ItemsSource = quotes.Collection; </code></pre> <hr> <pre><code>// selected Quote Quote quote; public QuotePage() { InitializeComponent(); // get selected quote from App Class var app = App.Current as App; quote = app.selectedQuote; // show quote details in page author.Text = quote.author; text.Text = quote.text; } </code></pre> <p>This work fine in every feed having this structure with one <code>&lt;text&gt;</code> section. But I have feed with a lot of <code>&lt;text&gt;</code></p> <p>If I use C# code above, only first <code>&lt;text&gt;</code> section is parsed, others are ignored. I need to create separate List or ObservableCollection for each <code>&lt;text&gt;</code> section in single XML feed.</p>
    singulars
    1. This table or related slice is empty.
    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