Note that there are some explanatory texts on larger screens.

plurals
  1. POXML Reader not Reading Child nodes Properly
    primarykey
    data
    text
    <p>I'm having a problem when reading some XML into a Windows 8 store app.</p> <p>I've got some XML with multiple parent and child nodes in which I need to only read one of the nodes and concatenate it all into a single string. I've tried many different ways to get it to loop through both parent nodes and extract the data from the single child node that the data needs to be read from. I'm using the XmlReader Class as that's the simplest way for me to be able to read it without too many problems.</p> <p>This is the XML I'm trying to read:</p> <pre><code>&lt;platforms&gt; &lt;platform&gt; &lt;api_detail_url&gt; &lt;![CDATA[ http://www.giantbomb.com/api/platform/3045-20/ ]]&gt; &lt;/api_detail_url&gt; &lt;id&gt;20&lt;/id&gt; &lt;name&gt; &lt;![CDATA[ Xbox 360 ]]&gt; &lt;/name&gt; &lt;site_detail_url&gt; &lt;![CDATA[ http://www.giantbomb.com/xbox-360/3045-20/ ]]&gt; &lt;/site_detail_url&gt; &lt;abbreviation&gt; &lt;![CDATA[ X360 ]]&gt; &lt;/abbreviation&gt; &lt;/platform&gt; &lt;platform&gt; &lt;api_detail_url&gt; &lt;![CDATA[ http://www.giantbomb.com/api/platform/3045-86/ ]]&gt; &lt;/api_detail_url&gt; &lt;id&gt;86&lt;/id&gt; &lt;name&gt; &lt;![CDATA[ Xbox Live Marketplace ]]&gt; &lt;/name&gt; &lt;site_detail_url&gt; &lt;![CDATA[ http://www.giantbomb.com/xbox-live-marketplace/3045-86/ ]]&gt; &lt;/site_detail_url&gt; &lt;abbreviation&gt; &lt;![CDATA[ XBLM ]]&gt; &lt;/abbreviation&gt; &lt;/platform&gt; &lt;/platforms&gt; </code></pre> <p>And this is my current attempt at reading it:</p> <pre><code>if(reader.ReadToDescendant("platform")) { do { i++; reader.ReadToDescendant("name"); reader.ReadStartElement("name"); gPlat = gPlat + reader.Value + Environment.NewLine; reader.ReadToFollowing("platform"); } while (reader.ReadToNextSibling("platform")); } </code></pre> <p>I can't seem to get it too loop through both "platform" nodes if it has any kind of other reader functions/methods inside the do/while loop, if I leave it blank it loops fine without any trouble (the i variable was used to test this)</p> <p>All I'm aiming for is a concatenated string with the two name child nodes as the value, but it only loops once through, skipping the second "name" node altogether. I am unable to change the XML as it's being returned by a web API.</p> <p>Any help is much appreciated.</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