Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I think this gives what you want, however your example was not quite consistent:</p> <pre><code>using System; using System.Collections.Generic; using System.IO; using System.Xml; using System.Xml.Serialization; namespace Serialize { class Program { static void Main( string[] args ) { var envelope = new CdsXmlEnvelope { TestValue1 = "x1", InnerList = new List&lt;CdsXmlInfo&gt; { new CdsXmlInfo {TestValue1 = "e1"}, new CdsXmlInfo {TestValue1 = "e1"}, new CdsXmlInfo {TestValue1 = "e1"}, } }; var ns = new XmlSerializerNamespaces(); ns.Add( string.Empty, string.Empty ); var serializer = new XmlSerializer( typeof( CdsXmlEnvelope ) ); using( var stream = new MemoryStream() ) { var settings = new XmlWriterSettings(); settings.OmitXmlDeclaration = true; settings.Indent = true; var writer = XmlWriter.Create( stream, settings ); serializer.Serialize( writer, envelope, ns ); stream.Position = 0; Console.WriteLine( new StreamReader( stream ).ReadToEnd() ); } Console.ReadLine(); } } [XmlRoot( "cdsXMLEnvelope" )] public class CdsXmlEnvelope { [XmlElement( "TestValue1" )] public string TestValue1 { get; set; } [XmlElement( "inner" )] public List&lt;CdsXmlInfo&gt; InnerList { get; set; } } public class CdsXmlInfo { [XmlElement( "TestValue1" )] public string TestValue1 { get; set; } [XmlAttribute] public string TestValue3 { get; set; } } } </code></pre> <p>giving output:</p> <pre><code>&lt;cdsXMLEnvelope&gt; &lt;TestValue1&gt;x1&lt;/TestValue1&gt; &lt;inner&gt; &lt;TestValue1&gt;e1&lt;/TestValue1&gt; &lt;/inner&gt; &lt;inner&gt; &lt;TestValue1&gt;e1&lt;/TestValue1&gt; &lt;/inner&gt; &lt;inner&gt; &lt;TestValue1&gt;e1&lt;/TestValue1&gt; &lt;/inner&gt; &lt;/cdsXMLEnvelope&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload