Note that there are some explanatory texts on larger screens.

plurals
  1. PODeserialize unknown section into List or Dictionary
    primarykey
    data
    text
    <p>I have the following XML file:</p> <pre><code>&lt;Error&gt;0&lt;/Error&gt; &lt;Description&gt;1&lt;/Description&gt; &lt;Document&gt; &lt;ObjectID&gt;06098INF1761320&lt;/ObjectID&gt; &lt;ced&gt;109340336&lt;/ced&gt; &lt;abstract&gt;DAVID STEVENSON&lt;/abstract&gt; &lt;ced_a /&gt; &lt;NAM_REC /&gt; &lt;ced_ap2 /&gt; &lt;/Document&gt; </code></pre> <p>So I deserialize it on C# (4.0) with this objects structure:</p> <pre><code> [XmlElement("Error")] public string Error { get; set; } [XmlElement("Description")] public string Description { get; set; } [XmlElement("Document")] public List&lt;EDocument&gt; LstDocument { get; set; } </code></pre> <p>So here's my issue: the element "Document" has unknown sub-elements: ObjectID, ced, etc., is there a way that I can deserialize those unknows elements into a List, Array, Dictionary or something to iterate with (something like this, it DOESN'T have to be exactly like this, I'm just guessing):</p> <pre><code>object.LstDocument[0].ListDocument.name; //to get the name object.LstDocument[0].ListDocument.value; //to get the value </code></pre> <p>Any help would be appreciated.</p> <p><strong>EDIT 1:</strong></p> <p>To add some extra clarification to my question: The child nodes under "Document" element are unknown because they are variable, with this I mean that at a moment I could have "ObjectID" and "ced", in other moment they could be "ced","ABC", etc. I'm not sure which elements came there as child nodes, all I know is that they are elements (not attributes) and that they don't have any child-nodes inside them.</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