这是一个用c#控制台程序下,  用XmlDocument 进行XML操作的的例子,包含了查询、增加、修改、删除、保存的基本操作。较完整的描述了一个XML的整个操作流程。适合刚入门.net XML操作的朋友参考和学习。

假设有XML文件:books.xml

 

 

 1[转]C#操作XML的完整例子——XmlDocument篇<?xml version="1.0" encoding="UTF-8"?>
 2[转]C#操作XML的完整例子——XmlDocument篇<books>
 3[转]C#操作XML的完整例子——XmlDocument篇 <book>
 4[转]C#操作XML的完整例子——XmlDocument篇  <name>哈里波特</name>
 5[转]C#操作XML的完整例子——XmlDocument篇  <price>10</price>
 6[转]C#操作XML的完整例子——XmlDocument篇  <memo>这是一本很好看的书。</memo>
 7[转]C#操作XML的完整例子——XmlDocument篇 </book>
 8[转]C#操作XML的完整例子——XmlDocument篇 <book id="B02">
 9[转]C#操作XML的完整例子——XmlDocument篇  <name>三国演义</name>
10[转]C#操作XML的完整例子——XmlDocument篇  <price>10</price>
11[转]C#操作XML的完整例子——XmlDocument篇  <memo>四大名著之一。</memo>
12[转]C#操作XML的完整例子——XmlDocument篇 </book>
13[转]C#操作XML的完整例子——XmlDocument篇 <book id="B03">
14[转]C#操作XML的完整例子——XmlDocument篇  <name>水浒</name>
15[转]C#操作XML的完整例子——XmlDocument篇  <price>6</price>
16[转]C#操作XML的完整例子——XmlDocument篇  <memo>四大名著之一。</memo>
17[转]C#操作XML的完整例子——XmlDocument篇 </book>
18[转]C#操作XML的完整例子——XmlDocument篇 <book id="B04">
19[转]C#操作XML的完整例子——XmlDocument篇  <name>红楼</name>
20[转]C#操作XML的完整例子——XmlDocument篇  <price>5</price>
21[转]C#操作XML的完整例子——XmlDocument篇  <memo>四大名著之一。</memo>
22[转]C#操作XML的完整例子——XmlDocument篇 </book>
23[转]C#操作XML的完整例子——XmlDocument篇</books>

 

 

下面是为Program.cs

 

 

 1[转]C#操作XML的完整例子——XmlDocument篇using System;
 2[转]C#操作XML的完整例子——XmlDocument篇using System.Collections.Generic;
 3[转]C#操作XML的完整例子——XmlDocument篇using System.Text;
 4[转]C#操作XML的完整例子——XmlDocument篇using System.Xml;
 5[转]C#操作XML的完整例子——XmlDocument篇
 6[转]C#操作XML的完整例子——XmlDocument篇namespace TestXml
 7

 

相关文章: