I am trying to generate an XML file from an Object. I put a break point before generating the XML file, so I can check the values. The object and its value look fine. However, after the XML file is generated, it is missing a key component, the code.
This is what I was expected to see.
<eDocument Code="UN" Cat="ST">
<id myId="5"/>
</eDocument>
This is the actual xml file that is generated.
<eDocument Cat="EST">
<id myId="5"/>
</eDocument>
This is the object that is being serialize to generate the xml file.
sDoc eDocument = new sDoc();
eDocument.Code = "UN";
eDocument.Cat = "ST";
eDocument.myId = new ID[1];
eDocument.myId[0].id= 5;
This is how I am saving the file
string fileName= "student.xml";
XmlSerializer serializeObject = new XmlSerializer(eDocument.GetType());
TextWriter streamWritter = new StreamWriter(Server.MapPath(@"~/student/" + fileName));
serializeObject.Serialize(streamWritter, eDocument); // I check the eDocument Object, and it has all the correct inforamtion
streamWritter.Close();
Is there something that I am doing wrong here?