title: Problem creating XML using c#
body: <p>I am searching a batter solution for creating xml through xml serialization. What i need, i have a given format like this</p>
  
  <pre><code>&lt;product Id="1"&gt;
    &lt;name&gt;2 1/2 X 6 PVC NIPPLE TOE SCH  80&lt;/name&gt;
    &lt;notes&gt;
       &lt;note&gt;!--note 1---&lt;/note&gt;
       &lt;note&gt;!--note 2--&lt;/note&gt;
  
       ......
       &lt;/notes&gt;
  
  &lt;/product&gt;
  </code></pre>
  
  <p>what i am doing here, i created a 2 classes like this</p>
  
  <pre><code>public class product
   {
     [XmlElement("name")]
     public string Name { get; set; }
  
     [XmlArray("notes")]
     public List&lt;notes&gt; ListNotes { get; set; }
   }
  
   public class notes
   {
       [XmlIgnore]
       public string Note { get; set; }
    }
  </code></pre>
  
  <p>when i am serializing this then i am getting xml in this formate</p>
  
  <pre><code> &lt;product Id="1"&gt;
        &lt;name&gt;2 1/2 X 6 PVC NIPPLE TOE SCH  80&lt;/name&gt;
        &lt;notes&gt;
          &lt;notes&gt;
           &lt;note&gt;!--note 1---&lt;/note&gt;
           &lt;note&gt;!--note 2--&lt;/note&gt;
          &lt;/notes&gt;
        &lt;/notes&gt;
    &lt;/product&gt;
  </code></pre>
  
  <p>i don't want extra <code>&lt;notes&gt;</code>. Any batter solution to solve this problem? 
  Thanks</p>
  
  <hr>
  
  <p><strong>Solution</strong></p>
  
  <pre><code> public class product
       {
         [XmlElement("name")]
         public string Name { get; set; }
  
         [XmlArray("notes")]
         public List&lt;notes&gt; ListNotes { get; set; }
       }
  
       public class notes
       {
           [XmlText]
           public string Note { get; set; }
        }
  
  
  
  
  product ObjProduct = new product
    {
     Name ="Pankaj",
     notes=new List&lt;note&gt;()
    }
  
   foreach (var note in item.ListNote)
    {
      ObjProduct.notes.Add(new Highmark.BLL.Common.note { Note = EncodeTo64(note.Note) });
     }
  </code></pre>
  
  <p>Now use this ObjProduct for serialization.</p>