Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

¹ØÓÚ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
ÊôÐÔµÄÖµ£¬²¢ÇÒ×


Ïà¹ØÎĵµ£º

XML ÈëÃűضÁ

1£®Ê²Ã´ÊÇXML£¿
XML ¿ª·¢ÕßÃÇ»á¸æËßÄ㣬ÊÂʵÉÏXML²¢²»ÊÇÒ»ÖÖÓïÑÔ£¬¶øÊÇÒ»ÖÖÓÃÀ´¶¨ÒåÆäËüÓïÑÔµÄϵͳ¡£¿ÉÄÜÄãÒѾ­Ìý¹ý£¬»òÐíÉõÖÁ×Ô¼º³¢ÊÔ¹ýһЩÕâÑùµÄÓïÑÔ??±ÈÈç΢ÈíΪÍÆ£¨push£©¼¼ÊõËùÍƳöµÄƵµÀ¶¨Òå¸ñʽ£¨Channel Definition Format£©¡£
W3CÊÇ»¥Á¬ÍøÉÏһЩ¹«Óñê×¼µÄ¿ª·¢Õߣ¬ËûÍƳöÁËһϵÁкÍXMLÏà¹ØµÄ±ê× ......

ÔÚXMLÀïдSQLÓï¾ä£¨°ÑSQLÓï¾äд½øXMLÀ

ÄãÖªµÀXMLÎļþ°É£¿£¨²»ÖªµÀµÄGOOGLEÈ¥£¡£©ÄÇÄãÌý˵¹ýÔÚXMLÀïÊéдSQLÓï¾äÂ𣿻»¾ä»°Ëµ£¬°ÑÄãµÄÏîÄ¿ÀïËùÓÐSQLÓï¾ä´æ´¢ÔÚXMLÎļþÀÄãÌý˵¹ýÂð£¿Äã×ö¹ýÂð£¿
ÎÒÍ·´ÎÌý˵ÊÇС°¬¸æËßÎҵģ¬ÎҸҿ϶¨ËûÊǸöÕâ·½ÃæµÄ¸ßÊÖ£¬ºÇºÇ£¨ÔÞÒ»¸ö£¬µ½´ËΪֹ£¡£©
ÄǸøÄãչʾһÏ£¬ÔÚXMLÀïÊéдSQLÓï¾ä°É
<commands>
  <comman ......

Java:Struts ÏîÄ¿ÖÐweb.xmlÎļþÅäÖÃ

 web.xmlÎļþ¶ÔÓÚÅäÖÃÈκÎJava WebÓ¦Óö¼±ØÐèµÄ¡£
£¨1£©ÅäÖÃStrutsµÄActionServlet
<servlet><!--ÔªËØÀ´ÉùÃ÷ActionServlet-->
<servlet-name><!--ÔªËØ£ºÓÃÀ´¶¨ÒåServletµÄÃû³Æ-->
<servlet-class><!--ÔªËØ:ÓÃÀ´Ö¸¶¨ServletµÄÍêÕûÀàÃû-->
<servlet>
<servlet-name& ......

xml±à³Ì2


.dtdÎļþÖÐÈç¹ûÓÐÖÐÎÄ,±ØÐëÁí´æΪUTF-8±àÂë
ÎÊÌâ:
TransformerFactoryΪ³éÏóÀà,²»ÄÜnewʵÀý,µ«ÌṩÁË·½·¨À´»ñµÃ
TransformerFactory factory = TransformerFacory.newInstance();
factory.newDocumentBuilder();
ÕâÀïnewDocumentBuilder()Ϊ³éÏó·½·¨,ΪʲôÄܵ÷ÓÃÄØ?
×¢Òâ:ÕâÀïfactory±äÁ¿Ö¸ÏòµÄÊÇÒ»¸öʵÀý,´ËʵÀýÊ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ