¹ØÓÚSQLServer2005µÄѧϰ±Ê¼Ç——XMLµÄ´¦Àí
ÔÚ
SQLServer2005
ÖжÔ
XML
µÄ´¦Àí¹¦ÄÜÏÔÈ»ÔöÇ¿Á˺ܶ࣬ÌṩÁË
query(),value(),exist(),modify(),nodes()
µÈº¯Êý¡£
¹ØÓÚ
xml
£¬ÄÑÒÔÀí½âµÄ²»ÊÇ
SQLServer
ÌṩµÄº¯Êý£¬¶øÊǶÔ
xml
±¾ÉíµÄÀí½â£¬¿´Ëƺܼòµ¥µÄÎļþ¸ñʽ£¬´¦ÀíÆðÀ´È´ÊǷdz£À§Äѵġ£±¾ÎÄÖ»Êdzõ̽һ϶øÒÑ¡£
Ïê¼û
SQLServer
Áª»ú°ïÖú£º
Ö÷Ìâ
˵Ã÷
query()
·½·¨£¨
xml
Êý¾ÝÀàÐÍ£©
´Ë·½·¨ÓÃÓÚ¶Ô
XML
ʵÀý½øÐвéѯ¡£
value()
·½·¨£¨
xml
Êý¾ÝÀàÐÍ£©
´Ë·½·¨ÓÃÓÚ´Ó
XML
ʵÀý¼ìË÷
SQL
ÀàÐ͵ÄÖµ¡£
exist()
·½·¨£¨
xml
Êý¾ÝÀàÐÍ£©
´Ë·½·¨ÓÃÓÚÈ·¶¨²éѯÊÇ·ñ·µ»Ø·Ç¿Õ½á¹û¡£
modify()
·½·¨£¨
xml
Êý¾ÝÀàÐÍ£©
´Ë·½·¨ÓÃÓÚÖ¸¶¨
XML DML
Óï¾äÒÔÖ´ÐиüС£
nodes()
·½·¨£¨
xml
Êý¾ÝÀàÐÍ£©
´Ë·½·¨ÓÃÓÚ½«
XML
²ð·Ö³É¶àÐÐÒÔ½«
XML
ÎĵµµÄ×é³É²¿·Ö´«²¥µ½ÐÐ
¼¯ÖС£
Ïл°ÉÙ˵£¬Ê×ÏÈ´´½¨Ò»¸ö°üº¬
xml
ÀàÐ͵ÄÊý¾Ý±í£¬Æä´Î´´½¨Ò»¸ö
xml
Îļþ£¬ÔÚ·þÎñ¶Ë°Ñ
xml
ÎļþÄÚÈݼÓÔظÃÊý¾Ý±íÖС£
CREATE
TABLE VisioXML
(
ID
INT,
Doc
XML
);
GO
´´½¨Ò»¸ö
ÃûΪ
xxx.xml
µÄÎļþ£¬ÄÚÈÝÈçÏÂ
/*
<ROOT>
<ROW>
<ID>1</ID>
<NAME SEX="MALE">WBQ</NAME>
</ROW>
<ROW>
<ID>2</ID>
<NAME SEX="FEMALE">CZH</NAME>
</ROW>
</ROOT>
*/
INSERT
INTO VisioXML(ID,Doc)
SELECT
4,* from OPENROWSET(BULK
'e:\xxx.xml',SINGLE_BLOB) AS x;
--
ÒÔÏÂΪ
value()
ºÍ
query()
µÄÓ÷¨
--SELECT
* from VisioXML WHERE ID=4
SELECT
Doc.value('(/ROOT/ROW[1]/ID/text())[1]','int') RootRowID1,
--
µÚÒ»ÐÐ
ID
µÄÖµ£¬²¢ÇÒת»»Îª
int
ÀàÐÍ
Doc.value('(/ROOT/ROW[2]/ID/text())[1]','int') RootRowID2,
--
µÚ¶þÐÐ
ID
µÄÖµ£¬²¢ÇÒת»»Îª
int
ÀàÐÍ
Doc.value('(/ROOT/ROW[1]/NAME/text())[1]','varchar(20)')
RootRowNAME1,
--
µÚÒ»ÐÐ
NAME
µÄÖµ£¬²¢ÇÒת»»Îª
VARCHAR
ÀàÐÍ
Doc.value('(/ROOT/ROW[1]/NAME/@SEX)[1]','varchar(20)')
RootRowNAME1SEX, --
µÚÒ»ÐÐ
NAME
ÖÐ
SEX
ÊôÐ
Ïà¹ØÎĵµ£º
ÏÖÔÚÒ»°ã³£ÓõÄÓÐÒÔÏÂ2ÖÖ·½·¨:
1. select top @pagesize * from table1 where id not in (select top @pagesize*(@page-1) id from table1 order by id) order by id
2. select * from (select top @pagesize * from (select top @pagesize*@page * from table1 order by id) a order by id desc) b or ......
°üλÖãºandroid.widget.TextView
XML Attributes
Attribute Name Related Method &n ......
Ç°Ì᣺1.JdomµÄ¼Ü¹¹ÒѾµ¼Èë
²½Ö裺
ÓÃJDOM¶ÁÈ¡XMLÎļþÐèÏÈÓÃorg.jdom.input.SAXBuilder¶ÔÏóµÄbuild()·½·¨´´½¨Document¶ÔÏó,
È»ºóÓÃDocumentÀà¡¢ElementÀàµÈµÄ·½·¨¶ÁÈ¡ËùÐèµÄÄÚÈÝ¡£
<?xml version="1.0" encoding="UTF-8"?>
<HD>
<disk name="C">
<capacity>8 ......
using System.Data.SqlClient;
using System.Data.OleDb;
private void button1_Click(object sender, EventArgs e)
{
OleDbConnection conn = null;
try
&nbs ......
XMLÏÖÔÚÒѾ³ÉΪһÖÖͨÓõÄÊý¾Ý½»»»¸ñʽ,ƽ̨µÄÎÞ¹ØÐÔʹµÃºÜ¶à³¡ºÏ¶¼ÐèÒªÓõ½XML¡£±¾ÎĽ«Ïêϸ½éÉÜÓÃJava½âÎöXMLµÄËÄÖÖ·½·¨¡£
XMLÏÖÔÚÒѾ³ÉΪһÖÖͨÓõÄÊý¾Ý½»»»¸ñʽ,ËüµÄƽ̨ÎÞ¹ØÐÔ,ÓïÑÔÎÞ¹ØÐÔ,ϵͳÎÞ¹ØÐÔ,¸øÊý¾Ý¼¯³ÉÓë½»»¥´øÀ´Á˼«´óµÄ·½±ã¡£¶ÔÓÚXML±¾ÉíµÄÓ﷨֪ʶÓë¼¼Êõϸ½Ú,ÐèÒªÔĶÁÏà¹ØµÄ¼¼ÊõÎÄÏ×,ÕâÀïÃæ°üÀ¨µÄÄÚÈÝ ......