Example:
public class MYELEMENT
{
public string value;
}
The above would produce something like the following:
<MYELEMENT><value>string</value></MYELEMENT>
For my purposes I need the following:
<MYELEMENT>string</MYELEMENT>
I am creating an array of elements that preserves the order of the original elements serialized from an external source.
public class MYROOT
{
[XmlElement(typeof(MYELEMENT1))]
[XmlElement(typeof(MYELEMENT2))]
[XmlElement(typeof(MYELEMENT3))]
public object[] nodes { get; set; }
}
There may be one or more elements of each type that can appear any order. Therefore, each element is represented as a class object.
The code, as written, works fine except that Deserializing this
<MYELEMENT>1</MYELEMENT>
produces the following when Serializing it out
<MYELEMENT />
Which is correct at the moment, because there is no sub-element.
Is there an XML attribute or other method that can be applied to produce what I need?
Something like this
public class MYELEMENT
{
[this is the elements value]
public string value;
}
or this
[this is a wrapper for the real element]
public class Foo
{
public string MYELEMENT { get; set; }
}
Thanks!