Note that there are some explanatory texts on larger screens.

plurals
  1. POXDocument LINQ complex syntax
    text
    copied!<p>I am upgrading from XmlSerialization to Linq-to-xml and finding it hard to get objects from this structure. </p> <p>I've tried suggestions from this post <a href="https://stackoverflow.com/questions/2874680/xmlserializer-deserialize-different-elements-as-collection-of-same-element">XmlSerializer - Deserialize different elements as collection of same element</a> </p> <p>but keep getting a null value trying to do this for the structures below. Thanks for your help.</p> <pre><code> var hbs = from f in doc.Descendants("cb").Descendants() select new Hb(f.Attribute("host").Value); public class Hb { public string a{ get; set; } public string aKey { get; set; } public string bKey { get; set; } } &lt;cb rootElement&gt;&lt;Hb xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema""&gt; &lt;host&gt;host01&lt;/host&gt; &lt;keyF&gt; &lt;a&gt;1&lt;/a&gt; &lt;aKey&gt;job_id&lt;/aKey&gt; &lt;bKey&gt;883b196a-6e2d-462a-9e3a-8a2021585629&lt;/bKey&gt; &lt;/keyF&gt; &lt;field&gt; &lt;a&gt;1&lt;/a&gt; &lt;aKey&gt;asset_state&lt;/aKey&gt; &lt;bKey&gt;STOPPED&lt;/bKey&gt; &lt;/field&gt; &lt;field&gt; &lt;a&gt;1&lt;/a&gt; &lt;aKey&gt;channel&lt;/aKey&gt; &lt;bKey&gt;1&lt;/bKey&gt; &lt;/field&gt; &lt;field&gt; &lt;a&gt;1&lt;/a&gt; &lt;aKey&gt;timecode_out&lt;/aKey&gt; &lt;bKey&gt;00:00:00.00&lt;/bKey&gt; &lt;/field&gt; &lt;field&gt; &lt;a&gt;1&lt;/a&gt; &lt;aKey&gt;% Processor Time 0&lt;/aKey&gt; &lt;bKey&gt;0.33&lt;/bKey&gt; &lt;/field&gt; &lt;/Hb&gt; &lt;/cb&gt; </code></pre>
 

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