I have this class…
[XmlRoot("config")]
public class SourceConfig
{
public string Description { get; set; }
public string HelpLink { get; set; }
}
…which I serialize into this…
<config>
<Description />
<HelpLink />
<param name="param1" value="" />
<param name="param2" value="" />
</config>
…using XmlSerializer + post-process using XmlDocument to add the <param> elements.
Is there a better way to serialize the <param> elements without post-processing using XmlDocument?
I tried using XmlArray attribute but the <param> elements ended up inside another node.
Make it an XmlElement:
Complete working example:
Outputs the following: