Possible Duplicate:
What is the best way to build XML in C# code?
what's the best method to generate xml file?
using XmlWriter
class in .Net
var writerSettings = new XmlWriterSettings();
writerSettings.Indent = true;
XmlWriter writer = XmlWriter.Create("d:\\MyFirstXmlFile.xml", writerSettings);
writer.WriteStartDocument();
writer.WriteStartElement("People");
writer.WriteStartElement("Person");
writer.WriteElementString("Name", "Zain Shaikh");
writer.WriteElementString("JobDescription", "Software Engineer");
writer.WriteElementString("Facebook", "http://www.facebook.com/zainshaikh");
writer.WriteEndElement();
writer.WriteEndElement();
writer.WriteEndDocument();
writer.Flush();
精彩评论