I'm trying to create a piece of XML that looks roughly like this:
<OuterTags>
<MiddleTags>
<Guests>
<Adult />
<Adult />
</Guests>
</MiddleTags>
</OuterTags>
However. Whenever I try to serialise this, I get:
<OuterTags>
<MiddleTags>
<Guests>
<Adult xsi:nil="true" />
<Adult xsi:nil="true" />
</Guests>
</MiddleTags>
</OuterTags>
...and I've proven that the xsi:nil="true"
attributes are being rejected by my endpoint.
The code that I have generating the MiddleTags currently exists in two classes:
using System;
using System.Xml.Serialization;
namespace XmlRobot.DataTypes
{
[Serializable]
public class MiddleTags
{
[XmlArray("Guests")]
[XmlArrayItem("Adult")]
public Adult[] Adults { get; set; }
}
}
...and...
using System;
using System.Xml.Serialization;
namespace XmlRobot.DataTypes
{
[Serializable]
public class Adult
{
}
}
I've found a question/answer here (Suppress xsi:nil but still show Empty Element when Serializing in .Net) that tells me how to make this tag work for a simple element (i.e. string/float), but I can't for the life of me make it work for my array!
Anyone got any pro advice?
Thanks, Tim