I have next xml:
<table-display-fields>
<field name="NAME/>
<field name="DESCRIPTION" />
</table-display-fields>
I deserealize that with next code:
[XmlArray("table-display-fields")]
[XmlArrayItem("field")]
public TableDisplayField[] TableDisplayFields;
Then I add new xml element to table-display-fields node:
<table-display-fields>
<record-number-field name="ID" />
<field name="NAME/>
<field name="DESCRIPTION" />
</table-display-fields>
Then add next code to deserealize record-number-field:
[XmlArray("table-display-fields")]
[XmlArrayItem("record-number-field")]
public TableDisplayField[] RecordTableDisplayFields;
[XmlArray("table-display-fields")]
[XmlArrayItem("field")]
public TableDisplayField[] TableDisplayFields;
This doesn't work. How do I deserealize new xml, and save the existing property path?
You must remove XmlArrayItem() attribute.
[XmlArray("table-display-fields")]
public object[] TableDisplayItems;
Each object in the TableDisplayItems
will be either a field
or a record-number-field
.
Of course, if you only have one single record-number-field
on top of your array, the solution can be much nicer. Is it the case ?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With