繁体中文
设为首页
加入收藏
当前位置:ASP技术首页 >> ASP应用 >> .Net FrameWork SDK文档的例子演示

.Net FrameWork SDK文档的例子演示

2005-08-29 00:11:03  作者:kgdiwss  来源:互联网  浏览次数:3  文字大小:【】【】【
简介:XmlDocument.CreateAttribute 效果演示using System;using System.IO;using System.Xml;namespace CreateAttribute{ /// <summary> /// Class1 的摘要说明。 /// </summary> cl...

XmlDocument.CreateAttribute 效果演示

using System;

using System.IO;

using System.Xml;

namespace CreateAttribute

{

///

/// Class1 的摘要说明。

///

class Class1

{

///

/// 应用程序的主入口点。

///

[STAThread]

static void Main(string[] args)

{

//

// TODO: 在此处添加代码以启动应用程序

//

XmlDocument doc = new XmlDocument();

doc.LoadXml("" +

"Pride And Prejudice" +

"");

//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);

}

}

}

效果如下:

Display the modified XML...

Pride And Prejudice

Press any key to continue

XmlDocument.CreateNode 方法效果演示

using System;

using System.Xml;

namespace CreateNode

{

///

/// Class1 的摘要说明。

///

class Class1

{

///

/// 应用程序的主入口点。

///

[STAThread]

static void Main(string[] args)

{

//

// TODO: 在此处添加代码以启动应用程序

//

XmlDocument doc = new XmlDocument();

doc.LoadXml("" +

" Oberon's Legacy" +

" 5.95" +

"");

// Create a new element node.

XmlNode newElem;

newElem = doc.CreateNode(XmlNodeType.Element, "pages", "");

newElem.InnerText = "290";

Console.WriteLine("Add the new element to the document...");

XmlElement root = doc.DocumentElement;

root.AppendChild(newElem);

Console.WriteLine("Display the modified XML document...");

Console.WriteLine(doc.OuterXml);

}

}

}

效果:

Add the new element to the document...

Display the modified XML document...

Oberon's Legacy5.95290

Press any key to continue

责任编辑:admin
相关文章