Creating XML problem using c#

Posted by Pankaj on Stack Overflow See other posts from Stack Overflow or by Pankaj
Published on 2010-06-03T06:10:32Z Indexed on 2010/06/03 6:14 UTC
Read the original article Hit count: 307

Filed under:
|

I am searching a batter solution for creating xml through xml serialization. What i need, i have a given format like this

<product Id="1">
  <name>2 1/2 X 6 PVC NIPPLE TOE SCH  80</name>
  <notes>
     <note>!--note 1---</note>
     <note>!--note 2--</note>

     ......
     </notes>

</product>

what i am doing here, i created a 2 classes like this

public class product
 {
   [XmlElement("name")]
   public string Name { get; set; }

   [XmlArray("notes")]
   public List<notes> ListNotes { get; set; }
 }

 public class notes
 {
     [XmlIgnore]
     public string Note { get; set; }
  }

when i am serializing this then i am getting xml in this formate

 <product Id="1">
      <name>2 1/2 X 6 PVC NIPPLE TOE SCH  80</name>
      <notes>
        <notes>
         <note>!--note 1---</note>
         <note>!--note 2--</note>
        </notes>
      </notes>
  </product>

i don't want extra . Any batter solution to solve this problem? Thanks

© Stack Overflow or respective owner

Related posts about c#

Related posts about xml-serialization