[C#]使用xmlWriter建立xml文件
使用xmlWriter建立xml文件
XmlWriter writer = null;
Encoding enc = Encoding.GetEncoding("big5");
XmlWriterSettings settings = new XmlWriterSettings();
settings.Indent = true;
settings.OmitXmlDeclaration = false;
settings.NewLineOnAttributes = true;
settings.Encoding = enc;
settings.Indent = true;
settings.IndentChars = ("\t");
spath = @"c:\" + sNow + ".xml";
writer = XmlWriter.Create(spath, settings);
writer.WriteStartElement("body");
writer.WriteElementString("d1", "001");
writer.WriteElementString("d2", "002");
writer.WriteEndElement();
writer.Flush();
沒有留言:
張貼留言