ASP.NET(C#)

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

using System;
using System.Xml;

public class Sample
{

 public static void Main()
 {
 
  // Create the XmlDocument.
  XmlDocument doc = new XmlDocument();
  doc.LoadXml("<item><name>wrench</name></item>");

  // Add a price element.
  XmlElement newElem = doc.CreateElement("price");
  newElem.InnerText = "10.95";
  doc.DocumentElement.AppendChild(newElem);

  // Save the document to a file and auto-indent the output.
  XmlTextWriter writer = new XmlTextWriter("D:\\data.xml",null);
  writer.Formatting = Formatting.Indented;
  doc.Save(writer);
 }
}

posted on 2005-03-18 14:25  battlerstar  阅读(787)  评论(0编辑  收藏  举报