Note that there are some explanatory texts on larger screens.

plurals
  1. POSpecific XML Attribute values into Class List
    primarykey
    data
    text
    <p>Its been a while since I last tried to program and has never worked with XML before. I have a internal website that display XML</p> <pre><code> &lt;Source&gt; &lt;AllowsDuplicateFileNames&gt;YES&lt;/AllowsDuplicateFileNames&gt; &lt;Description&gt;The main users ....&lt;/Description&gt; &lt;ExportSWF&gt;FALSE&lt;/ExportSWF&gt; &lt;HasDefaultPublishDir&gt;NO&lt;/HasDefaultPublishDir&gt; &lt;Id&gt;28577db1-956c-41f6-b775-a278c39e20a1&lt;/Id&gt; &lt;IsAssociated&gt;YES&lt;/IsAssociated&gt; &lt;LogoURL&gt;http://servername:8080/logos/9V0.png&lt;/LogoURL&gt; &lt;Name&gt;Portal1&lt;/Name&gt; &lt;RequiredParameters&gt; &lt;RequiredParameter&gt; &lt;Id&gt;user_name&lt;/Id&gt; &lt;Name&gt;UserID&lt;/Name&gt; &lt;PlaceHolder&gt;username&lt;/PlaceHolder&gt; &lt;ShowAsDescription&gt;true&lt;/ShowAsDescription&gt; &lt;/RequiredParameter&gt; &lt;/RequiredParameters&gt; </code></pre> <p>I don't want the values in the child tags, there is time where there will be more than one portal thus the need/want to use a list. I only need the values inside of the Name and ID tags. also if there is a blank ID tag I don't want to store the either one of them.</p> <p>My current approach to this is not working as expected:</p> <pre><code>String URLString = "http://servername:8080/roambi/SourceManager"; XmlTextReader reader = new XmlTextReader(URLString); List&lt;Portal&gt; lPortals = new List&lt;Portal&gt;(); String sPortal = ""; String sId = ""; while (reader.Read()) { //Get Portal ID if (reader.NodeType == XmlNodeType.Element &amp;&amp; reader.Name == "Id") { reader.Read(); if (reader.NodeType == XmlNodeType.Text) { sId = reader.Value; } } //Get Portal Name if (reader.NodeType == XmlNodeType.Element &amp;&amp; reader.Name == "Name") { reader.Read(); if (reader.NodeType == XmlNodeType.Text) { sPortal = reader.Value; } //Fill Portal List with Name and ID if (sId != "" &amp;&amp; sPortal != "") { lPortals.Add(new Portal { Portalname = sPortal, Portalid = sId }); } } } foreach (Portal i in lPortals) { Console.WriteLine(i.Portalname + " " + i.Portalid); } </code></pre> <p>See my standard class</p> <pre><code>class Portal { private String portalname; private String portalid; public String Portalname { get { return portalname; } set { portalname = value; } } public String Portalid { get { return portalid; } set { portalid = value; } } } </code></pre> <p>Please give me some advice and point me into a direction, As I said its been a while since I last programmed. My current Output is as follow:</p> <pre><code>Portal1 28577db1-956c-41f6-b775-a278c39e20a1 UserID user_name </code></pre> <p>UserID is in a child node and I do not want to display child nodes</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