xml procedure
DECLARE @XMLdoc XML
SET @XMLdoc =
'<Book name="SQL Server 2000 Fast Answers">
<Chapters>
<Chapter id="1" name="Installation, Upgrades">
<CreateDate>2009-12-30</CreateDate>
</Chapter>
<Chapter id="2" name="Configuring SQL Server"/>
<Chapter id="3" name="Creating and Configuring Databases">
<CreateDate>2009-12-30</CreateDate>
</Chapter>
<Chapter id="4" name="SQL Server Agent and SQL Logs"/>
</Chapters>
</Book>'
DECLARE @docpointer int
EXEC sp_XML_preparedocument @docpointer OUTPUT, @XMLdoc
SELECT *
from OPENXML (@docpointer, '/Book/Chapters/Chapter',1)
WITH (Chapter int '@id',
ChapterNM varchar(50) '@name',
CreateDate VARCHAR(50) './CreateDate/text()')
GO
结果如下:
Chapter ChapterNM CreateDate
1 Installation, Upgrades 2009-12-30
2 Configuring SQL Server NULL
3 Creating and Configuring Databases 2009-12-30
4 SQL Server Agent and SQL Logs
相关文档:
C#
DataSet ds = new DataSet();
ds.ReadXml(Server.MapPath("~/Config/User_yhlx_Jb.xml"));
DataView dv = ds.Tables[0].DefaultView;
//dv.RowFilter = "State=0";
this.DropDownList1.DataSource = dv;
this.DropDownList1.DataTextField = "text";
this ......
protected void Button1_Click(object sender, EventArgs e)
{
//为response(star)节点 和 Cabins(f) cabin节点分别添加个
&nbs ......
XML Schema import 元素
定义和用法
import 元素用于向一个文档添加带有不同目标命名空间的多个 schema。
元素信息
出现次数
无限制
父元素
schema
内容
annotation
语法
<import
id=ID
namespace=anyURI
schemaLocation=anyURI
any attributes
>
(annotation?)
< ......
XML Schema union 元素
定义和用法
union 元素定义多个 simpleType 定义的集合。
元素信息
出现次数
一次
父元素
simpleType
内容
annotation、simpleType
语法
<union
id=ID
memberTypes="list of QNames"
any attributes
>
(annotation?,(simpleType ......
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
SAXReader reader = new SAXReader();
try {
Document doc = reader.read("ParserSQL.xml");
&n ......