Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I make xml with lot of same tags and show they in textblock
    text
    copied!<p>I want to read my xml and then in c# code generate textblock to add all datas in their textlock, make something like a table or list.</p> <p>My xml is:</p> <pre><code> &lt;?xml version="1.0"?&gt; &lt;players&gt; &lt;player&gt; &lt;id&gt;10101&lt;/id&gt; &lt;name&gt;Ricardo Ferreira Rodrigues&lt;/name&gt; &lt;shirtnumber&gt;1&lt;/shirtnumber&gt; &lt;position&gt;Guarda Redes&lt;/position&gt; &lt;/player&gt; &lt;player&gt; &lt;id&gt;10102&lt;/id&gt; &lt;name&gt;Manuel Lopes&lt;/name&gt; &lt;shirtnumber&gt;2&lt;/shirtnumber&gt; &lt;position&gt;fixo&lt;/position&gt; &lt;/player&gt; &lt;/players&gt; </code></pre> <p>And my code is:</p> <pre><code> private async void LoadXml() { try { StorageFolder storageFolder = Package.Current.InstalledLocation; StorageFile storageFile = await storageFolder.GetFileAsync("players2.xml"); string xml = await FileIO.ReadTextAsync(storageFile, Windows.Storage.Streams.UnicodeEncoding.Utf8); var doc = XDocument.Parse(xml); var rootNode = doc.Root; foreach (var child in rootNode.Descendants("player")) { //I try this //TextBlock txtnome = new TextBlock(); //TextBlock txtshirtnumber = new TextBlock(); //TextBlock txtposition = new TextBlock(); txtnome.Text = (string)doc.Root.Element("name"); txtshirtnumber.Text = (string)doc.Root.Element("shirtnumber"); txtposition.Text = (string)doc.Root.Element("position"); } } </code></pre> <p>but this textblock i make it and i want the code to generate then because I will need to add lot of players.</p> <p>My Erro is "values cannot be null".</p> <p>Someone can help me?</p>
 

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