📄 sample21.cs
字号:
namespace apiBook
{
using System;
using System.Xml;
using System.IO;
using System.Data;
public class TestClass
{
public static void Main()
{
XmlDataDocument testXDD = new XmlDataDocument();
//使用无参数的构造函数创建对象
testXDD.DataSet.ReadXmlSchema("C:\\school.xsd");
testXDD.Load("c:\\school.xml");
//使用Load方法装载数据
Console.WriteLine("原始数据:");
Console.WriteLine(testXDD. DocumentElement. OuterXml);
Console.WriteLine();
XmlElement testXE = testXDD.DocumentElement;
DataRow testDR = testXDD.GetRowFromElement((XmlElement)testXE.FirstChild);
//使用GetRowFromElement方法检索与指定XmlElement对象关联的DataRow对象
testDR["name"] = "Jack";
Console.WriteLine("将Mike的名该为Jack");
Console.WriteLine("修改后的数据:");
Console.WriteLine (testXDD.DocumentElement.OuterXml);
Console.WriteLine("克隆的对象包含的数据:");
XmlDataDocument cloneXDD=(XmlDataDocument)testXDD.CloneNode(true);
//使用CloneNode方法创建当前节点的副本
Console.WriteLine(testXDD.DocumentElement.OuterXml);
Console.ReadLine();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -