0

Possible Duplicate:
What is the best way to build XML in C# code?

what's the best method to generate xml file?

Community
  • 1
  • 1
user496949
  • 83,087
  • 147
  • 309
  • 426
  • this question is duplicate of http://stackoverflow.com/questions/284324/what-is-the-best-way-to-build-xml-in-c-code – ratty Nov 17 '10 at 05:12

1 Answers1

1

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();
Zain Shaikh
  • 6,013
  • 6
  • 41
  • 66