生成xml文件的最佳方法是什么?
答案 0 :(得分:1)
在.Net
中使用XmlWriter
类
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();