I want to serialise XML documents from a third-party service that either come in as any of the two formats (I added indenting for easier readability):
1.
<STADMessage>Invalid Request, no content provided!</STADMessage>
2.
<STADMessage>
<Message>Invalid Request, see log for detail using reference: ASDFL210359872305982035</Message>
</STADMessage>
Right now I'm hacking the XML document before it gets serialised with the following code
xmlDocument.Replace("<STADMessage><Message>", "<STADMessages><Message>")
.Replace("</Message></STADMessage>", "</Message></STADMessages>");
Snippet of the serialised class
[XmlElement(ElementName = "STADMessage", IsNullable = true)]
public string STADMessage { get; set; }
[XmlArray(ElementName = "STADMessages", IsNullable = true)]
[XmlArrayItem("Message", typeof(string))]
public List<string> STADMessages { get; set; }
Is there a cleaner way?