SqlServer²Ù×÷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 ÎĵµµÄ×é³É²¿·Ö´«²¥µ½Ðм¯ÖС£
CREATE TABLE VisioXML
(
ID INT,
Doc XML
);
GO
INSERT INTO VisioXML(ID,Doc)
SELECT 4,* from OPENROWSET(BULK 'c:\abc.xml',SINGLE_BLOB) AS x;
--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 ÊôÐÔµÄÖµ£¬²¢ÇÒת»»Îª VARCHAR ÀàÐÍ
Doc.query('/ROOT') Root, --ROOT ϵÄËùÓÐ XML ÄÚÈÝ£¬ÀàÐÍΪ XML
--Doc.query('/ROOT/ROW[1]') RootRow1, --ROOT ϵÚÒ»ÐÐËùÓÐµÄ XML ÄÚÈÝ£¬ÀàÐÍΪ XML
Doc.query('/ROOT/ROW[2]') RootRow2 --ROOT ϵڶþÐÐËùÓÐµÄ XML ÄÚÈÝ£¬ÀàÐÍΪ XML
from VisioXML
WHERE ID=4
SELECT
Doc.exist('/ROOT/ROW[1]/NAME[(@SEX cast as xs:string?) = xs:string("MALE")]') Row1EQStringMale,
Doc.exist('/ROOT/ROW[1]/NAME[(@SEX cast as xs:string?) = "MALE"]') Row1EQ
Ïà¹ØÎĵµ£º
<?xml version="1.0" standalone="yes"?>
<imgs>
<pic name="/adv_pic/1.jpg" url="http://www.baidu.com/" title="test" />
<pic name="/adv_pic/2.jpg" url="http://www.baidu.com/" title="test" />
......
FusionCharts µÄ XML±êÇ©ÊôÐÔÓÐÒ»ÏÂËÄÖÖÊý¾ÝÀàÐÍ
* Boolean - ²¼¶ûÀàÐÍ£¬Ö»ÄÜΪ1»òÕß0¡£ÀýÈ磺<graph showNames=’1′ >
* Number - Êý×ÖÀàÐÍ£¬Ö»ÄÜΪÊý×Ö¡£ÀýÈ磺<graph yAxisMaxValue=’200′ >
* String - ×Ö·û´®ÀàÐÍ£¬Ö»ÄÜΪ×Ö·û´®¡£ÀýÈ磺 <graph caption=’My Chart&rsqu ......
»¥ÁªÍø·¢Õ¹µÃºÜ¿ì£¬¶¼ÊÇÔ´×ÔÓÚʹÓÃÁ˳¬Îı¾µÄ±í´ï·½Ê½¡£±ÈÈçÄã²é¿´Ò»ÆªÎÄÕ£¬¿´µ½²»¶®µÄ¹Ø¼ü×Ö£¬¾Í¿ÉÒÔͨ¹ýÁ´½ÓÈ¥²é¿´ËüµÄÄÚÈÝ£¬¿´ÍêÖ®ºóÔÙ»ØÀ´½Ó×Å¿´ÔÀ´µÄ¶«Î÷£¬ÕâÑù±È½ÏÊʺÏѧϰµÄ·½Ê½¡£Ê¹ÓÃHTML±ê¼ÇµÄÎı¾£¬Êǽṹ»¯´¢´æµÄ£¬ÕâÑùµÄ±í´ï·½Ê½²Å¿ÉÒÔʵÏÖ³¬¼¶Á¬½Ó¡£ÓÉÓÚHTML¾ßÓг¬Ç¿µÄ±í´ïÄÜÁ¦£¬Ò²¾ÍÔÚ»¥ÁªÍøÉÏÉú´æÏÂÀ´£¬ÄÇ ......
ת×Ô£ºhttp://lbccheng.blog.163.com/blog/static/314120920095525627390/
ÎÊÌâÒ»£ºÊ¹ÓÃJasperReportÉú³ÉHtml±¨±íºó£¬Êý¾ÝÏÔʾÕýÈ·£¬µ«¸÷ÖÖÏßÌõÏÔʾ²»³öÀ´
²úÉúÔÒò£ºÔÚ Éú³ÉHTMLÒ³ÃæʱJRHtmlExporterParameter.IMAGES_URI²ÎÊýÉèÖò»ÕýÈ·£¬Ö÷ÒªÊÇͼƬµÄ ......
¶ÔÓÚ´øÓбí¿Õ¼äxmlnsµÄxmlÎļþµÄ½âÎö£¬ÓÃÕý³£½âÎöÎļþµÄ·½·¨×ÜÊÇʧЧ£¬²»Æð×÷Óã¬ÎÞ·¨»ñµÃÔªËØ¡£
ÏÂÃæ¸ø³öÁ½ÖÖ·½·¨½âÎö´ËÀàÎļþ£º
1.°´Õý³£½âÎöxmlÎļþµÄ·½·¨£¬ÐèҪעÒ⼸µã£º
»ñÈ¡ÔªËØElement£¬²»¿ÉʹÓú¯Êý£ºdocument.selectNodes("//region");
Ö»¿ÉÒÔÏÈÈ¡µ½¸ùÔªËØ£¬Ò»¼¶Ò»¼¶ÍùÏÂÈ¡£¬eg£º
Element root = document.g ......