Note that there are some explanatory texts on larger screens.

plurals
  1. POXML Deserialization skips elements
    primarykey
    data
    text
    <p>I have this XML structure (excert from a larger file - only this part makes problems)</p> <pre><code>&lt;Table&gt; &lt;Row id="1"&gt; &lt;Heading&gt;sgjsfgjsgfh443q572q356&lt;/Heading&gt; &lt;Items&gt; &lt;Item car="motor1" id="1"&gt; &lt;BodyText color="red"&gt;130*&lt;/BodyText&gt; &lt;Subscript&gt;3&lt;/Subscript&gt; &lt;/Item&gt; &lt;/Items&gt; &lt;/Row&gt; &lt;/Table&gt; </code></pre> <p>And try to deserialize it with <code>XmlSerializer</code> to this model (also excert for the parts matching the XML):</p> <pre><code>[XmlRoot("Table")] public partial class Table { [XmlElement("Row")] public Row[] Row { get; set; } } [XmlRoot("Row")] public partial class Row { [XmlElement("Heading")] public string Heading { get; set; } [XmlElement("Items")] public Item[] Items { get; set; } [XmlElement("BodyText")] public BodyText BodyText { get; set; } [XmlAttribute("id")] public string id { get; set; } } [XmlRoot("Items")] public partial class Items { [XmlElement("Item")] public Item[] Item { get; set; } } [XmlRoot("Item")] public partial class Item { [XmlElement("BodyText")] public BodyText BodyText { get; set; } [XmlElement("PhoneNumber")] public PhoneNr[] PhoneNr { get; set; } [XmlElement("Subscript")] public Subscript[] Subscript { get; set; } [XmlAttribute("car")] public string car { get; set; } [XmlAttribute("id")] public string id { get; set; } } [XmlRoot("BodyText")] public partial class BodyText { [XmlAttribute("color")] public string color { get; set; } [XmlAttribute("fonttype")] public string fonttype { get; set; } [XmlAttribute("fontsize")] public string fontsize { get; set; } [XmlAttribute("fontweight")] public string fontweight { get; set; } [XmlText] public string Value { get; set; } } [XmlRoot("Subscript")] public partial class Subscript { [XmlAttribute("for")] public string @for { get; set; } [XmlText] public string Value { get; set; } } [XmlRoot("PhoneNr")] public partial class PhoneNr { [XmlElement("Display")] public string Display { get; set; } [XmlElement("Number")] public string Number { get; set; } [XmlAttribute("id")] public string id { get; set; } } </code></pre> <p>The resulting object for the <code>Table</code> class contains a single <code>Row</code> element, which is fine, but: The elements inside <code>Row</code> are all null. It seems the serializer can't match the <code>Items</code> to their classes.</p> <p>What can I do, so the <code>Items</code> and <code>Item</code> are correctly deserialized into objects?</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.
 

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