XmlÖÐSelectSingleNode·½·¨ÖеÄxpathÓ÷¨
×î³£¼ûµÄXMLÊý¾ÝÀàÐÍÓУºElement, Attribute£¬Comment, Text.
Element, Ö¸ÐÎÈç<Name>Tom<Name>µÄ½Úµã¡£Ëü¿ÉÒÔ°üÀ¨£ºElement, Text, Comment, ProcessingInstruction, CDATA, and EntityReference.
Attribute, Ö¸ÔÚ<Employee >ÖеĴÖÌ岿·Ö¡£
Comment£¬Ö¸ÐÎÈ磺<!-- my comment --> µÄ½Úµã¡£
Text£¬Ö¸ÔÚ<Name>Tom<Name>µÄ´ÖÌ岿·Ö¡£
ÔÚXMLÖУ¬¿ÉÒÔÓÃXmlNode¶ÔÏóÀ´²ÎÕÕ¸÷ÖÖXMLÊý¾ÝÀàÐÍ¡£
2.1 ²éѯÒÑÖª¾ø¶Ô·¾¶µÄ½Úµã£¨¼¯£©
objNodeList = objDoc.SelectNodes(“Company/Department/Employees/Employee”)
»òÕß
objNodeobjNodeList = objNode.SelectNodes(“/Company/Department/Employees/Employee”)
ÒÔÉÏÁ½ÖÖ·½·¨¿É·µ»ØÒ»¸öNodeList¶ÔÏó£¬Èç¹ûÒª·µ»Øµ¥¸ö½Úµã¿ÉʹÓÃSelectSingleNode·½·¨£¬¸Ã·½·¨Èç¹û²éѯµ½Ò»¸ö»ò¶à¸ö½Úµã£¬·µ»ØµÚÒ»¸ö½Úµã£»Èç¹ûûÓвéѯµÄÈκνڵ㷵»Ø Nothing¡£ÀýÈ磺
objNodeobjNode = objNode.SelectSingleNode(“/Company/Department/Employees/Employee”)
If Not (objNode is Nothing) then
‘- Do process
End If
2.2 ²éѯÒÑÖªÏà¶Ô·¾¶µÄ½Úµã£¨¼¯£©
¿ÉʹÓÃÀàËÆÓÚÎļþ·¾¶µÄÏà¶Ô·¾¶µÄ·½Ê½À´²éѯXMLµÄÊý¾Ý
objNode = objDoc.SelectSingleNode(“Company/Department”)
objNodeobjNodeList = objNode.SelectNodes(“../Department)
objNodeobjNode = objNode.SelectNode(“Employees/Employee”)
2.3 ²éѯÒÑÖªÔªËØÃûµÄ½Úµã£¨¼¯£©
ÔÚʹÓò»¹æÔòµÄ²
Ïà¹ØÎĵµ£º
Ò»¡¢ÒýÑÔ
Èç½ñ£¬ÔÚSQL Server 2005ÖУ¬XML³ÉΪµÚÒ»Á÷µÄÊý¾ÝÀàÐÍ¡£½èÖúÓÚ»ùÓÚXMLģʽµÄÇ¿ÀàÐÍ»¯Ö§³ÖºÍ»ùÓÚ·þÎñÆ÷¶ËµÄXMLÊý¾ÝУÑ鹦ÄÜ£¬ÏÖÔÚ
£¬¿ª·¢Õß¿ÉÒÔ¶Ô´æ´¢µÄXMLÎĵµ½øÐÐÇáËɵØÔ¶³ÌÐ޸ġ£×÷ΪÊý¾Ý¿â¿ª·¢Õߣ¬Ðí¶àÈ˶¼±ØÐë´óÁ¿µØÉæ¼°XML¡£
Èç½ñ£¬ÔÚSQL Server 2005ÖУ¬ÄãÄÜÒÔÒ»ÖÖеÄÊý¾ÝÀàÐ͵ÄÐÎʽ°ÑXML´æ´¢ÔÚÊý¾Ý¿âÖÐ ......
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
xmlѧϰ£ºhttp://www.w3school.com.cn/x.asp ......
1¡¢³õʼ»¯
Load µ¼ÈëÒ»¸öXMLÎļþµ½CMarkupµÄ¶ÔÏóÖУ¬²¢¶ÔËü½øÐнâÎö¡£ÀàËÆC#µÄLoad¡£
SetDoc ´Ó×Ö·û´®Öе¼ÈëXMLÊý¾Ý£¬²¢¶ÔËü½âÎö¡£ÀàËÆC#µÄLoadXml¡£
2¡¢Êä³ö
Save ½«XMLÊý¾ÝдÈëÎļþÖС£ÀàËÆC#µÄSave¡£
GetDoc ½«Õû¸öXMLÊý¾ÝÎĵµ×÷Ϊ×Ö·û´®·µ»Ø¡£
3¡¢¸Ä±äµ±Ç°Î»ÖÃ
FindElem ¶¨Î»µ½ÏÂÒ»¸öÔªËØ£¬¿ÉÄܺÍÒ»¸ö±êÇ©Ãû»ò· ......
sql2005ÖÐÒ»¸öxml¾ÛºÏµÄÀý×Ó ÊÕ²Ø
¸ÃÎÊÌâÀ´×ÔÂÛ̳ÌáÎÊ£¬ÑÝʾSQL´úÂëÈçÏÂ
--½¨Á¢²âÊÔ»·¾³
set nocount on
create table test(ID varchar(20),NAME varchar(20))
insert into test select '1','aaa'
insert into test select '1','bbb'
insert into test select '1','ccc'
insert into test select '2','ddd'
inser ......
SGML¹ýÓÚ¸´ÔÓ£¬¹Ø¼üÖ®´¦»¹ÔÚÓÚÖ÷Á÷ä¯ÀÀÆ÷³§É̲»Ö§³ÖSGML£¬webÓ¦ÓúܺÃ
Little version£ºXML
html => xhtml =>xml¿ÉÒÔÀí½â³ÉÊÇÒ»¸ö¹ý¶ÉµÄ¹ý³Ì
SGMLµÄÉè¼ÆÀíÄî¾ÍÊÇ°ÑÎı¾µÄÄÚÈݺÍÑùʽ·Ö¿ª£¬×ÔÈ»xmlÒ²ÊÇÈç´Ë¡£
xmlÒ»°ã°üÀ¨ÒÔÏÂÎļþ£º
DTD-->schema(xsd) ¶¨ÒåÎĵµ½á¹¹µÈ£¨ÄÚÈÝ£©
CSS-->XSLT (Ñùʽ)
xml ---- ......