当前位置:编程学习 > C#/ASP.NET >>

.Net FrameWork SDK文档的例子演示

XmlDocument.CreateAttribute 效果演示
using System;
using System.IO;
using System.Xml;
namespace CreateAttribute
{
 /// <summary>
 /// Class1 的摘要说明。
 /// </summary>
 class Class1
 {
    /// <summary>
    /// 应用程序的主入口点。
    /// </summary>
    [STAThread]
    static void Main(string[] args)
    {
     //
     // TODO: 在此处添加代码以启动应用程序
     //
     XmlDocument doc = new XmlDocument();
     doc.LoadXml("<book genre='novel' ISBN='1-861001-57-5'>" +
    "<title>Pride And Prejudice</title>" +
    "</book>");
     //Create an attribute.
     XmlAttribute attr = doc.CreateAttribute("publisher");
     attr.Value = "WorldWide Publishing";
    
     //Add the new node to the document.
     doc.DocumentElement.SetAttributeNode(attr);
    
     Console.WriteLine("Display the modified XML...");    
     doc.Save(Console.Out);
补充:asp.net教程,基础入门 
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,