⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sample27.cs

📁 C#函数手册
💻 CS
字号:
namespace apiBook
{
	using System;
	using System.Xml;
	using System.IO;
	public class TestXMLDocumentFragmentClass 
	{ 
		public static void Main()
		{			   
			XmlDocument testXD = new XmlDocument();
			string str="<student Id='1'>" +"<name><firstN>Li</firstN><lastN>Ze</lastN></name>"+"<dept>Computer</dept>"+"</student>";
			testXD.LoadXml(str);
			XmlDocumentFragment testXDF = testXD.CreateDocumentFragment();
			testXDF.InnerXml ="<dept>Computer</dept>";
			XmlNode testXND = testXDF.CloneNode(true);
			Console.WriteLine("浅拷贝: " + testXND.Name);
			Console.WriteLine("拷贝节点内容: " + testXND.OuterXml);
			XmlNode testXNS = testXDF.CloneNode(false);
			Console.WriteLine("深拷贝:" + testXNS.Name);
			Console.WriteLine("拷贝节点内容: " + testXNS.OuterXml); 
			Console.WriteLine("XmlDocument 节点内容:");
			XmlTextWriter writer = new XmlTextWriter(Console.Out);
			writer.Formatting = Formatting.Indented;
			testXD.WriteContentTo( writer );
			writer.Flush();
			Console.WriteLine();
			Console.WriteLine("XmlDocument节点的所有子级");
			writer = new XmlTextWriter(Console.Out);
			writer.Formatting = Formatting.Indented;
			testXD.WriteTo( writer );
			writer.Flush();
			Console.WriteLine();
			Console.ReadLine();
		}	
	}
}

⌨️ 快捷键说明

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