There are couple of ways to create an XML document.
If you want to create an XML representation of a class you should
consider using Xml serialization. Check the following :
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnexxml/html/xml01202003.asp
http://www.devhood.com/tutorials/tutorial_details.aspx?tutorial_id=236
Now, if you want to create an XML document without using a class you
should check the System.Xml namespace. A small example could be
(coppied from MSDN)
static void WriteQuote(XmlWriter writer, string symbol,
double price, double change, long volume)
{
writer.WriteStartElement("Stock");
writer.WriteAttributeString("Symbol", symbol);
writer.WriteElementString("Price", XmlConvert.ToString(price));
writer.WriteElementString("Change", XmlConvert.ToString(change));
writer.WriteElementString("Volume", XmlConvert.ToString(volume));
writer.WriteEndElement();
}
public static void Main(){
XmlTextWriter writer = new XmlTextWriter(Console.Out);
writer.Formatting = Formatting.Indented;
WriteQuote(writer, "MSFT", 74.125, 5.89, 69020000);
writer.Close();
}
Check this also :
ms-help://MS.MSDNQTR.2005APR.1033/cpguide/html/cpconWritingXMLWithXmlWriter.htm