How to serialize objects to xml?

Then use the XmlSerializer for an instance of objClassA and it will automatically place the instance of the be inside itself as a child.

Serializable(true) public class objClassB { } Serializable(true) public class objClassA { public objClassB instance; } Then use the XmlSerializer for an instance of objClassA and it will automatically place the instance of the be inside itself as a child.

But, I don't need the class B instance inside Class A. I just need to frame the xml in the above format. Is there any other way?

– NewBie Oct 11 at 3:52 You'll have to serialize it yourself (custom). – jberger Oct 11 at 4:00 In that case you need to implement IXmlSerializable on your class and add the WriteXml and ReadXml methods. Inside there you can add whatever child elements you desire.

– Phil Wright Oct 11 at 22:58.

Using System; using System. IO; using System.Xml. Serialization; void Write(root rootInstance) { XmlSerializer xmlSerializer = new XmlSerializer(typeof(root)); using (FileStream fileStream = new FileStream("filepath.

Xml", FileMode. Create)) { xmlSerializer. Serialize(fileStream, rootInstance); } } public class root { public ClassA objClassA { get; set; } } public class ClassA { public ClassB objClassB { get; set; } } public class ClassB { }.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions