C#小Tip:Xml操作简明手册 1
1)Xml文档示例(xmlsample.xml):
Code
<?xml version="1.0" encoding="iso-8859-1" ?>
<music>
<song title="Oh,girl">
<artist>The Chi-lites</artist>
<genre>Soul</genre>
<album>A lonely man</album>
<year>1972</year>
</song>
<song title="What if">
<artist>Babyface</artist>
<genre>R&B</genre>
<album>unknown</album>
<year></year>
</song>
<song title="How come,how long">
<artist>Babyface</artist>
<genre>R&B</genre>
<album>The essential babyface</album>
<year>2001</year>
</song>
<song title="Drama,love &'lationship">
<artist>Babyface</artist>
<genre>R&B</genre>
<album>Grown and sexy</album>
<year>2005</year>
</song>
<song title="Burning">
<artist>Maria Arredondo</artist>
<genre>Pop</genre>
<album>Not going under</album>
<year>2004</year>
</song>
<song title="Run">
<artist>Leona Lewis</artist>
<genre>Pop</genre>
<album>Unknown</album>
<year>2008</
相关文档:
连接sql server数据库用到的命名空间是using System.Data.SqlClient;
数据库连接代码:可以在大类之下声明 public SqlConnection myConnection; //sql连接对象
&nbs ......
/// <summary>
/// 读取数据集并加入缓存
/// sea 2009-12-11
/// </summary>
&nb ......
XML Schema union 元素
定义和用法
union 元素定义多个 simpleType 定义的集合。
元素信息
出现次数
一次
父元素
simpleType
内容
annotation、simpleType
语法
<union
id=ID
memberTypes="list of QNames"
any attributes
>
(annotation?,(simpleType ......
XML解析器的作用:为应用程序从XML文件中解析出所需要的数据。
下面通过一个例子,来了解,如何用XML解析器,来解析一个XML文件中的数据。
1、Types.xml(显示吉他的类别)
<?xml version="1.0" encoding="UTF-8"?>
<types>
<name>电吉他
<music>玩摇滚</music>
</name>
......