ch10_10.cs

来自「《c#技术内幕代码》」· CS 代码 · 共 31 行

CS
31
字号
using System;
using System.Xml;

public class CH10_10
{
   public static void Main(string[] args)
   {
        // Create an XML writer.
        XmlTextWriter myXmlTextWriter = new XmlTextWriter ("ch10_10.xml", null);
	
        myXmlTextWriter.Formatting = Formatting.Indented;
        myXmlTextWriter.WriteStartDocument(false);
        myXmlTextWriter.WriteDocType("ch10_10", null, null, null);
        myXmlTextWriter.WriteComment("This file represents some user data");
	
        for ( int i=0; i<args.Length; ++i )
	{
           myXmlTextWriter.WriteStartElement(args[i]);
           myXmlTextWriter.WriteStartElement("entry", null);
              myXmlTextWriter.WriteAttribute("date","Today");
              myXmlTextWriter.WriteAttribute("reason","Because");
              myXmlTextWriter.WriteAttribute("ID", i.ToString());
           myXmlTextWriter.WriteEndElement();
	}
        // Commit the data
        myXmlTextWriter.Flush();
        myXmlTextWriter.Close();
   }
}
   

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?