Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>this one is pretty tricky because you have items that have items which probably could have items too... so if you do something like this</p> <pre><code>var returnResult = (from r in document.Descendants("item") select r).ToList(); </code></pre> <p>you will get all the items separated and one which has all the values in one... </p> <p>edit:</p> <p>this works somewhat fine</p> <pre><code>XDocument document = XDocument.Load(@"XMLFile1.xml"); List&lt;Item&gt; items = new List&lt;Item&gt;(); var returnResult = (from r in document.Descendants("item") select r).ToList(); foreach (XElement xElement in returnResult) { Item item = new Item(); item.Key = xElement.Element("key") != null ? xElement.Element("key").Value : ""; item.Value = xElement.Element("value") != null ? xElement.Element("value").Value : ""; items.Add(item); } //sort the list to get the one that have the rest to the end var sorted = (from s in items orderby s.Value.Length ascending select s).ToList(); List&lt;Item&gt; finalList = new List&lt;Item&gt;(); items.Clear(); for (int i = 0; i &lt; sorted.Count - 1; i++) { for (int j = 1; j &lt; sorted.Count; j++) { if (sorted[j].Value.Contains(sorted[i].Value) &amp;&amp; sorted[j].Value.Length &gt; sorted[i].Value.Length) { Item itm = new Item(); itm.Key = sorted[j].Key; KeyValuePair&lt;string, string&gt; kvp = new KeyValuePair&lt;string, string&gt;(sorted[i].Key,sorted[i].Value); itm.Items.Add(kvp); items.Add(itm); } else { if (!finalList.Contains(sorted[i])) finalList.Add(sorted[i]); } } } class Item { public List&lt;Item&gt; Items { get; set; } public string Key { get; set; } public string Value {get;set;} public Item() { Items = new List&lt;Item&gt;(); } } </code></pre> <p>you can now see all sub items with their correct key... only the ok/error is making some trouble... but you can get them from the final list and pick them if they are not any of the key-value pairs...</p> <p>hope this helps</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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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