- 热门文章:
- · 利用.NET语言开发自己的脚本语言(一)
- · .NET中的数据类型的一些变化
- · 网上发现的文章(测试驱动开发)
- · .NET程序实现多语言
- · .NET Framework中使用XML Web Service(2)
- · .NET Framework中使用XML Web Service(1)
- · 管理三元式的新思路,涉及到查询时似乎可以借用Social Network的思想
- · 使用AOP微型框架的例子
- · VB.NET中使用FTP下载文件的两种方法
- · .net下基于API封装的DirectUIHWND窗体访问
- · 在.net中调用存储过程的另一种方法
- · .NET Remoting 实现分布式数据库查询
.Net FrameWork SDK文档的例子演示
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);
}
}
}
效果如下:
Display the modified XML...
<?xml version="1.0" encoding="gb2312"?>
<book genre="novel" ISBN="1-861001-57-5" publisher="WorldWide Publishing">
<title>Pride And Prejudice</title>
</book>Press any key to continue
XmlDocument.CreateNode 方法效果演示
using System;
using System.Xml;
namespace CreateNode
{
/// <summary>
/// Class1 的摘要说明。
/// </summary>
class Class1
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main(string[] args)
{
//
// TODO: 在此处添加代码以启动应用程序
//
XmlDocument doc = new XmlDocument();
doc.LoadXml("<book>" +
" <title>Oberon@#s Legacy</title>" +
" <price>5.95</price>" +
"</book>");
// 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...
<book><title>Oberon@#s Legacy</title><price>5.95</price><pages>290</pages></book>
Press any key to continue
- · 使用CodeDom开发基于B/S的.NET+MSSQL代码生成器的随感
- · 利用.NET的Reflection增强对象工厂的扩展性
- · .NET框架中基于角色的安全性(3)
- · .NET框架中基于角色的安全性(2)
- · .NET框架中基于角色的安全性(1)
- · .net的4个基本概念
- · 部署.net平台的程序
- · .net中何有效的使用Cache
- · 关于如何操作其他窗体的控件或变量的方法!
- · .net官方编码方法和命名规则
- · .NET 开发AutoCAD2006指南(二)
- · .NET开发AutoCAD指南(一)
- · 用.net 2003开发Windows CE应用,解决与pocket pc通讯的问题
- · .NET 开发AutoCAD2006指南(二)
- · 《.NET软件技术学习与实践》之序言
- · .net remoting范例
- · .net缓存应用与分析
- · 一种改进的轻量级.NET应用程序性能测试框架
- · 用.NET创建Windows服务
- · .net中清除EXCEL进程最有效的方法
- · 初探.NET中的delegate类型与.NET事件
- · .NET中自己构建一个ArrDictionary
- · 使用.NET生成Excel文件
- · 根据函数名称定位函数
- · .Net项目制作安装程序
- · 使用.net下的系统事件增强应用程序
- · Dotnet总结(4)--xml读写
- · Dotnet总结(3)--打印
- · Dotnet总结(2)--访问ms sql server 数据库基类--2
- · 如何使用.NET配置文件(一)
- · 将.aspx文件和图片编译进dll
- · .net如何实现页面间的参数传递
- · Microsoft .NET 中的简化加密
- · .Net远程方法调用研究
- · .net 里面 protected private 的变量也可以访问
- · 构建基本的.NET Remoting应用程序
- · 让你的.NET程序兼容不同版本的Dll文件
- · 谈Microsoft .NET战略
