开发者

what's the best method to generate xml file [duplicate]

This question already has answers here: Clo开发者_如何学JAVAsed 12 years ago.

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();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜