I need to serialize an array that has multiple nested values ββi.e.
<MyArray> <Code>code1</Code> <Name>name associated with code 1</Name> <Code>code2</Code> <Name>name associated with code 2</Name> <Code>code3</Code> <Name>name associated with code 3</Name> <Code>code4</Code> <Name>name associated with code 4</Name> </MyArray>
I tried various attributes in my array - for example,
[XmlArray(ElementName="MyArray")] [XmlArrayItem(ElementName="")] public List<MyPair> MyPairs { get; set; }
NB: the MyPair object contains 2 string properties (code and name):
but to no avail, I always get a containing element for each pair (which is usually better, but not what the circuit requires), and which I have no control over). Any help was greatly appreciated.
EDIT . This is part of a huge XML document, is it possible to use manual serialization of XElement for 1 part of it and XMLSerialization for the rest?
source share