In fact, I wrote this article as an answer of one among questions posted as a part of a C sharp corner forum. I will enumerate methods of how to do that through three articles, the first one illustrates how to do that using DOM technology, the second step, I'll do the same think using SAX technology and finally I will use some classes provided by the .Net framework to achieve the same task.
First way as said, using DOM technology witch is the "Document Object Model" abbreviation witch is largely adopted by several platforms across the development environments. It consists on an in memory XML document representation that not only allows xml generation, but allows several tasks such as manipulation, reading and modification of a given xml document. I illustrate how to use DOM by this walkthrough called Walkthrough1:
Walkthrough 1:
Create a new console application project then add this code within the scope of the main method:
//Create a new xmlDataDocument
XmlDataDocument myDoc = new XmlDataDocument();
//The familie
XmlElement Familie = myDoc.CreateElement("Familie");
//The elements wrapper
XmlElement wrapper = myDoc.CreateElement("xml");
//Create attributes
XmlAttribute version = myDoc.CreateAttribute("version");
XmlAttribute encoding = myDoc.CreateAttribute("encoding");
//Add values to attributes
version.Value = "1.0";
encoding.Value = "utf-8";
//Append attributes to their correspondent element
wrapper.Attributes.Append(version);
wrapper.Attributes.Append(encoding);
//The Father
XmlElement Father = myDoc.CreateElement("Father");
//Create attributes
XmlAttribute FatherName = myDoc.CreateAttribute("Name");
XmlAttribute FatherAge = myDoc.CreateAttribute("Age");
//Add values to attributes
FatherName.Value = "My father";
FatherAge.Value = "65";
//Append attributes to their correspondent element
Father.Attributes.Append(FatherName);
Father.Attributes.Append(FatherAge);
//Add the element to the Familie node
Familie.AppendChild(Father);
//The mother
XmlElement Mother = myDoc.CreateElement("Mother");
//Create attributes
XmlAttribute MotherName = myDoc.CreateAttribute("Name");

Vanadana PPosted Sep 26, 2017, 2:27 AM
Hi, i need following tag please help me how do i write it in c# -- "<?xml version="1.0" encoding="UTF-8"?><package xmlns="http://apple.com/itunes/importer" version="film5.2"><provider>applemusic</provider><language>en-US</language> <video> <type>film</type> <subtype>feature</subtype>"
Former memberPosted May 21, 2009, 3:15 PM
Hello; i have some difficult to create a Xml file with CDATA section; Exactly, my problem, is to retreive all label of my form and create xml file with this format <MarkUp name="label1"><![CDATA[Cdata1]]></MarkUp> Can you help me ? best regard