Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Your XML Document is has two root elements, both of type "player".</p> <p>Your code is trying to load that into an XDocument and it is having trouble because of that.</p> <p>Try wrapping your xml elements in a container node like so...</p> <pre><code>&lt;players&gt; &lt;player /&gt; &lt;!-- copied from above --&gt; &lt;player /&gt; &lt;!-- copied from above --&gt; &lt;/players&gt; </code></pre> <p>Then you will need to rewrite your queries to look at the child nodes of the root element. Note that since you have multiples of them, you should probably try to read them into a collection.</p> <pre><code>string xml = "&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;realteam&gt;5&lt;/realteam&gt;" + " &lt;/player&gt;" + " &lt;player&gt;" + " &lt;id&gt;10103&lt;/id&gt;" + " &lt;name&gt;Antonio Manuel&lt;/name&gt;" + " &lt;shirtnumber&gt;2&lt;/shirtnumber&gt;" + " &lt;position&gt;Defesa&lt;/position&gt;" + " &lt;realteam&gt;5&lt;/realteam&gt;" + " &lt;/player&gt;" + "&lt;/players&gt;"; var doc = XDocument.Parse(xml); var rootNode = doc.Root; foreach (var child in rootNode.Descendants("player")) { // do something with the values of the child nodes here. } </code></pre> <p>Note that within the loop it doesn't make sense to assign these values to the text controls you have as only the last one in the collection will get written out in a manner the user can make use of.</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.
    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