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 ²éѯÒÑÖªÔªËØÃûµÄ½Úµã£¨¼¯£©
ÔÚʹÓò»¹æÔòµÄ²
Ïà¹ØÎĵµ£º
value·½·¨
µ±Äã²»Ïë½âÊÍÕû¸ö²éѯµÄ½á¹û¶øÖ»ÏëµÃµ½Ò»¸ö±êÁ¿ÖµÊ±£¬Õâ¸övalue·½·¨ÊǺÜÓаïÖúµÄ¡£Õâ¸övalue·½·¨ÓÃÓÚ²éѯXML²¢ÇÒ·µ»ØÒ»¸öÔ×ÓÖµ¡£
Õâ¸övalue·½·¨µÄÓï·¨ÈçÏ£º
value(XQuery£¬datatype)
½èÖúÓÚvalue·½·¨£¬Äã¿ÉÒÔ´ÓXMLÖеõ½µ¥¸ö±êÁ¿Öµ¡£Îª´Ë£¬Äã±ØÐëÖ¸¶¨XQueryÓï¾äºÍÄãÏëÒªËü·µ»ØµÄÊý¾ÝÀàÐÍ£¬²¢ÇÒÄã¿ÉÒÔ·µ»Ø³ ......
import java.io.File;
import java.util.concurrent.CountDownLatch;
import com.sleepycat.db.Environment;
import com.sleepycat.db.EnvironmentConfig;
import com.sleepycat.db.LockDetectMode;
import com.sleepycat.dbxml.XmlContainer;
import com.sleepycat.dbxml.XmlContainerConfig;
im ......
ÏÖÔںܶàÈí¼þ¶¼ÊÇÒÔxmlÎļþ×÷ΪÊý¾ÝÔ´£¬¶øºÜ¶àÊý¾Ý¹¤¾ßÈçpbµÈÈ´Ö»ÄÜÁí´æΪtxt¡¢excelµÈ¸ñʽ£¬Îª´ËÐèÒªÒ»¹¤¾ßÄܽ«txtÎı¾×ª»»³ÉxmlÎļþ¡£googleÁËһϣ¬Ã»ÕÒµ½ºÏÊʵģ¬³å¶¯Ö®ÏÂÓÃC#дÁËÒ»¸ötxtÎı¾×ªxml¸ñʽÎı¾µÄС³ÌÐò£¬´úÂëÈçÏ¡£
н¨Ò»¸öw ......
ÄãÖªµÀXMLÎļþ°É£¿£¨²»ÖªµÀµÄGOOGLEÈ¥£¡£©ÄÇÄãÌý˵¹ýÔÚXMLÀïÊéдSQLÓï¾äÂ𣿻»¾ä»°Ëµ£¬°ÑÄãµÄÏîÄ¿ÀïËùÓÐSQLÓï¾ä´æ´¢ÔÚXMLÎļþÀÄãÌý˵¹ýÂð£¿Äã×ö¹ýÂð£¿
ÎÒÍ·´ÎÌý˵ÊÇС°¬¸æËßÎҵģ¬ÎҸҿ϶¨ËûÊǸöÕâ·½ÃæµÄ¸ßÊÖ£¬ºÇºÇ£¨ÔÞÒ»¸ö£¬µ½´ËΪֹ£¡£©
ÄǸøÄãչʾһÏ£¬ÔÚXMLÀïÊéдSQLÓï¾ä°É
<commands>
<comman ......
web.xmlÎļþ¶ÔÓÚÅäÖÃÈκÎJava WebÓ¦Óö¼±ØÐèµÄ¡£
£¨1£©ÅäÖÃStrutsµÄActionServlet
<servlet><!--ÔªËØÀ´ÉùÃ÷ActionServlet-->
<servlet-name><!--ÔªËØ£ºÓÃÀ´¶¨ÒåServletµÄÃû³Æ-->
<servlet-class><!--ÔªËØ:ÓÃÀ´Ö¸¶¨ServletµÄÍêÕûÀàÃû-->
<servlet>
<servlet-name& ......