using System;
using System
using System
namespace CreateAttribute
{
/// <summary>
/// Class
/// </summary>
class Class
{
/// <summary>
/// 應用程序的主入口點
/// </summary>
[STAThread]
static void Main(string[] args)
{
//
// TODO: 在此處添加代碼以啟動應用程序
//
XmlDocument doc = new XmlDocument();
doc
//Create an attribute
XmlAttribute attr = doc
attr
//Add the new node to the document
doc
Console
doc
}
}
}
效果如下
Display the modified XML
<?xml version=
<book genre=
<title>Pride And Prejudice</title>
</book>Press any key to continue
XmlDocument
using System;
using System
namespace CreateNode
{
/// <summary>
/// Class
/// </summary>
class Class
{
/// <summary>
/// 應用程序的主入口點
/// </summary>
[STAThread]
static void Main(string[] args)
{
//
// TODO: 在此處添加代碼以啟動應用程序
//
XmlDocument doc = new XmlDocument();
doc
// Create a new element node
XmlNode newElem;
newElem = doc
newElem
Console
XmlElement root = doc
root
Console
Console
}
}
}
效果
Add the new element to the document
Display the modified XML document
<book><title>Oberon@#s Legacy</title><price>
Press any key to continue
From:http://tw.wingwit.com/Article/program/net/201311/12330.html