I have some xml that I need to deserialize:
<MysteryXml niceAttribute="I know">
<UnknownNode attr1="someValue" attr2="anotherValue"> <- this nodes attributes and children are unknows
<Name>
<Value />
<AnotherValue />
</Name>
<CreatedBy>Unit Test</CreatedBy>
</UnknownNode>
<KnownNode nice="anotherAttr" />
</MysteryXml>
I have a C# class to deserialize the xml to
[Serializable()]
[DesignerCategory("code")]
[XmlType(AnonymousType = true)]
[XmlRoot(ElementName = "MysteryXml", IsNullable = false)]
public class MysteryXml
{
[XmlElement]
// Here I have a node[] but I would like an XElement
// If I set the type to XElement I only get the child node
public object? UnknownNode { get; set; }
[XmlElement]
public KnownNode KnownNode { get; set; }
[XmlAttribute]
public string niceAttribute {get;set;}
}
Is it possible to get the full xml as a string or XElement for UnknownNode using XmlSerializer?
Thanks