Note that there are some explanatory texts on larger screens.

plurals
  1. POSelect number of data based of a specific node
    primarykey
    data
    text
    <p>I have the following piece of code</p> <pre><code>XmlDocument docu = new XmlDocument(); docu.Load(file); XmlNodeList lst = docu.GetElementsByTagName("name"); foreach (XmlNode n in lst) { string text = n.InnerText; var types = doc.Element("program").Element("program-function").Element("function").Descendants("type").Where(x =&gt; x.Value == text).Select(c =&gt; c.Value).ToArray(); } </code></pre> <p>my xml is as follows</p> <pre><code>&lt;program&gt; &lt;program-function&gt; &lt;function&gt; &lt;name&gt;add&lt;/name&gt; &lt;return-type&gt;double&lt;/return-type&gt; &lt;params&gt; &lt;type&gt;double&lt;/type&gt; &lt;type-value&gt;a&lt;/type-value&gt; &lt;type&gt;double&lt;/type&gt; &lt;type-value&gt;b&lt;/type-value&gt; &lt;type&gt;string&lt;/type&gt; &lt;type-value&gt;c&lt;/type-value&gt; &lt;/params&gt; &lt;body&gt; return a + b + c; &lt;/body&gt; &lt;/function&gt; &lt;function&gt; &lt;name&gt;test&lt;/name&gt; &lt;return-type&gt;int&lt;/return-type&gt; &lt;params&gt; &lt;type&gt;double&lt;/type&gt; &lt;type-value&gt;a&lt;/type-value&gt; &lt;type&gt;double&lt;/type&gt; &lt;type-value&gt;b&lt;/type-value&gt; &lt;/params&gt; &lt;body&gt; return a + b; &lt;/body&gt; &lt;/function&gt; &lt;/program-function&gt; &lt;/program&gt; </code></pre> <p>i need to be able to get the number of <code>&lt;type&gt;</code> for each <code>&lt;name&gt;</code></p> <p>result for add should be 3 = <code>types.count() = 3</code><br> result for test should be 2 = <code>types.count() = 2</code> </p> <p>any advice? </p> <p>EDIT : If i want to retrieve each value inside <code>types</code>? ie. <code>add</code> should contain <code>a</code>,<code>b</code>,<code>c</code> and <code>test</code> should contain <code>a</code>,<code>b</code>. Would love to store it in an array for easier retrieval</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