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

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 Server2005µÄXMLÊý¾ÝÀàÐÍÖ®»ù´¡Æª1

Ò»¡¢ÒýÑÔ
Èç½ñ£¬ÔÚSQL Server 2005ÖУ¬XML³ÉΪµÚÒ»Á÷µÄÊý¾ÝÀàÐÍ¡£½èÖúÓÚ»ùÓÚXMLģʽµÄÇ¿ÀàÐÍ»¯Ö§³ÖºÍ»ùÓÚ·þÎñÆ÷¶ËµÄXMLÊý¾ÝУÑ鹦ÄÜ£¬ÏÖÔÚ
£¬¿ª·¢Õß¿ÉÒÔ¶Ô´æ´¢µÄXMLÎĵµ½øÐÐÇáËɵØÔ¶³ÌÐ޸ġ£×÷ΪÊý¾Ý¿â¿ª·¢Õߣ¬Ðí¶àÈ˶¼±ØÐë´óÁ¿µØÉæ¼°XML¡£
Èç½ñ£¬ÔÚSQL Server 2005ÖУ¬ÄãÄÜÒÔÒ»ÖÖеÄÊý¾ÝÀàÐ͵ÄÐÎʽ°ÑXML´æ´¢ÔÚÊý¾Ý¿âÖÐ ......

SQL Server2005µÄXMLÊý¾ÝÀàÐÍÖ®»ù´¡Æª2

value·½·¨
µ±Äã²»Ïë½âÊÍÕû¸ö²éѯµÄ½á¹û¶øÖ»ÏëµÃµ½Ò»¸ö±êÁ¿ÖµÊ±£¬Õâ¸övalue·½·¨ÊǺÜÓаïÖúµÄ¡£Õâ¸övalue·½·¨ÓÃÓÚ²éѯXML²¢ÇÒ·µ»ØÒ»¸öÔ­×ÓÖµ¡£
Õâ¸övalue·½·¨µÄÓï·¨ÈçÏ£º
value(XQuery£¬datatype)
½èÖúÓÚvalue·½·¨£¬Äã¿ÉÒÔ´ÓXMLÖеõ½µ¥¸ö±êÁ¿Öµ¡£Îª´Ë£¬Äã±ØÐëÖ¸¶¨XQueryÓï¾äºÍÄãÏëÒªËü·µ»ØµÄÊý¾ÝÀàÐÍ£¬²¢ÇÒÄã¿ÉÒÔ·µ»Ø³ ......

C#ÖÐÓÃXmlDocument¶ÔÏó»ñÈ¡XMLÎļþÖеĽڵãÖµ

 xmlÎļþ:
<?xml version="1.0" encoding="utf-8" ?>
<bookstore>
  <book>
    <title lang="eng">Harry Potter</title>
    <price>29.99</price>
  </book>
  <book>
......

ʹÓà XStreamʵÏÖJavaBean Óë XML/JSON Ö®¼äÏ໥ת»»

XML ºÍ JSON Êǵ±½ñ³£ÓõÄÁ½ÖÖÊý¾ÝÃèÊöÓë´«ÊäµÄ¸ñʽ£¬ÌرðÊÇÉæ¼°µ½ JS ʱʹÓà JSON ÆÄΪƵ·±¡£×ÔÈ»£¬ÔÚ Java  µÄÊÀ½çÀïÉÙ²»ÁËÍê³É JavaBean ÓëÕâÁ½ÖÖ¸ñʽÏ໥ת»»µÄ×é¼þ£¬ÄǾÍÊÇ XStream ºÍ JSON-lib¡£ÕâÀïÎÒ¼òµ¥¼ÇÏ XStream  µÄÓ÷¨¡£
ÆäʵÏàÀàËƵŤ¾ßÔçÒÑÓÐÖ®¡£Èç¹ûÓùý DWR µÄͬ־£¬Ò»¶¨ÓÐÓ¡Ïñ£¬DWR ½øÐÐÔ¶ ......

´«ÖDz¥¿Í—XML»ù´¡£¨Ï£©

½ñÌì¼ÌÐø½²XML£¬ÕùÈ¡ÔÚÏÂÎç5µãÇ°Õ¼ÁìXML¸ßµØ¡£Ò»¹²Èý¸öÖ÷ÒªÄÚÈÝ£ºSAX½âÎö¼¼Êõ£¬DOM4JºÍSCHEMA¡£
Ê×ÏÈÊÇSAX½âÎö¼¼Êõ£ºSAX²ÉÓÃʼþ´¦ÀíµÄ·½Ê½½âÎöXMLÎļþ¡£ÀûÓà SAX ½âÎö XML Îĵµ£¬Éæ¼°Á½¸ö²¿·Ö£º½âÎöÆ÷ºÍʼþ´¦ÀíÆ÷¡£
½âÎöÆ÷¸ºÔð¶ÁÈ¡ XML Îĵµ£¬²¢Ïòʼþ´¦ÀíÆ÷·¢ËÍʼþ
ʼþ´¦ÀíÆ÷¸ºÔð¶Ôʼþ×ö³öÏàÓ¦£¬¶Ô´«µÝµÄ XML Êý¾Ý ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ