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

xmlѡȡµ¥¸ö½ÚµãÄÚÈݽâ¾ö°ì·¨

XPath Óï·¨
2007-06-05 17:24
XPath Óï·¨
×÷Õß:w3pop.com ·­Òë/ÕûÀí:w3pop.com ·¢²¼:2007-04-29 ä¯ÀÀ:674 :: ::
XPath Nodes(½Úµã) XPath Axes
XPath uses path expressions to select nodes or node-sets in an XML document. The node is selected by following a path or steps.
XPath ͨ¹ý·¾¶±í´ïʽ´ÓXMLÎĵµÖÐѡȡ½Úµã»ò½ÚµãÉèÖ᣿ÉÒÔͨ¹ýÒ»ÌõÓï¾ä»òÏàÓ¦µÄ²½Öèѡȡһ¸ö½Úµã¡£
The XML Example Document
XMLÎĵµÊµÀý
We will use the following XML document in the examples below.
ÎÒÃǽ«ÔÚ½ÓÏÂÀ´µÄÎÄÕÂÖÐÒýÓÃÕâ¸öXMLÎĵµ¡£
<?xml version="1.0" encoding="ISO-8859-1"?>
<bookstore>
<book>
   <title lang="eng">Harry Potter</title>
   <price>29.99</price>
</book>
<book>
   <title lang="eng">Learning XML</title>
   <price>39.95</price>
</book>
</bookstore>
Selecting Nodes
ѡȡ½Úµã
XPath uses path expressions to select nodes in an XML document. The node is selected by following a path or steps. The most useful path expressions are listed below:
XPathͨ¹ý·¾¶±í´ïʽÔÚXMLÎĵµÖÐѡȡ½Úµã¡£¿ÉÒÔͨ¹ýÒ»ÌõÓï¾ä»òÏàÓ¦µÄ²½Öèѡȡһ¸ö½Úµã¡£ÏÂÃæÁгöÁË×ʹÓõÄ·¾¶±í´ïʽ£º
Expression
±í´ïʽ
Description
×¢ÊÍ
nodename
Selects all child nodes of the node
ѡȡ½ÚµãϵÄËùÓÐ×Ó½Úµã
/
Selects from the root node
ѡȡ¸ù½Úµã
//
Selects nodes in the document from the current node that match the selection no matter where they are
ѡȡÎĵµÖÐËùÓзûºÏÌõ¼þµÄ½Úµã£¬²»¹Ü¸Ã½ÚµãλÓںδ¦
.
Selects the current node
ѡȡµ±Ç°½Úµã
..
Selects the parent of the current node
ѡȡµ¥Ç°½ÚµãµÄ¸¸½Úµã
@
Selects attributes
ѡȡÊôÐÔ
Examples
ʵÀý
In the table below we have listed some path expressions and the result of the expressions:
ÔÚÏÂÃæµÄ±í¸ñÖУ¬ÎÒÃÇÁгöÁËһЩ·¾¶±í´ïʽ¼°ÆäÔËÐеĽá¹û£º
Path Expression
±í´ïʽ
Result
½á¹û
bookstore
Selects all the child nodes of the bookstore element
ѡȡbookstoreÔªËØµÄËùÓÐ×Ó½Úµã
/bookstore
Selects the root element bookstore
Ñ


Ïà¹ØÎĵµ£º

xml procedure

DECLARE @XMLdoc XML
SET @XMLdoc =
'<Book name="SQL Server 2000 Fast Answers">
<Chapters>
<Chapter id="1" name="Installation, Upgrades">
 <CreateDate>2009-12-30</CreateDate>
</Chapter>
<Chapter id="2" name="Configuring SQL Server"/>
<Chapter i ......

Jdbc,Jdo,XML·½Ãæ


1¡¢Class.forNameµÄ×÷ÓÃ?ΪʲôҪÓÃ?
´ð£ºµ÷Óø÷ÃÎÊ·µ»ØÒ»¸öÒÔ×Ö·û´®Ö¸¶¨ÀàÃûµÄÀàµÄ¶ÔÏó¡£
2¡¢JdoÊÇʲô?
´ð£ºJDOÊÇJava¶ÔÏó³Ö¾Ã»¯µÄеĹ淶£¬Îªjava data objectµÄ¼ò³Æ,Ò²ÊÇÒ»¸öÓÃÓÚ´æÈ¡Ä³ÖÖÊý¾Ý²Ö¿âÖеĶÔÏóµÄ±ê×¼»¯API¡£JDOÌṩÁË͸Ã÷µÄ¶ÔÏó´æ´¢£¬Òò´Ë¶Ô¿ª·¢ÈËÔ±À´Ëµ£¬´æ´¢Êý¾Ý¶ÔÏóÍêÈ«²»ÐèÒª¶îÍâµÄ´úÂ루ÈçJDBC ......

¹ØÓÚdom4j¡¢domÈçºÎÇåÀíÄÚ´æÖÐÒѾ­¼ÓÔØµÄxmlÊ÷

ĿǰÔÚʹÓÃDOMºÍdom4j¶ÔXMLÎļþ½øÐÐÔöɾ¸Ä²é£¬Èç¹ûÎÒÔÚͬһ¸öÏß³ÌÖÐ×ö¶à´ÎÔöɾ¸Ä²Ù×÷£¬ÈçºÎ±£Ö¤DOMÄÚ´æÍ¬²½ºÍÎïÀíÎļþͬ²½£¿ÓÖÈçºÎÇåÀíÔÚÄÚ´æÖÐÒѼÓÔØµÄÊý¾Ý£¿
ÎÊÌâ²¹³ä£º
Äã˵µÄÕâÖÖ¾ÍÊǺܵ¥´¿µÄÔÚÒ»¸öÏß³ÌÖÐÖ´ÐÐËùÓеIJÙ×÷£¬Èç¹ûÎÒÊÇÔÚµ¥Ïß³ÌÖвÙ×÷£¬Ã¿×öÒ»´ÎÔöɾ¸Ä²éµÄÒ»ÖÖ£¬ÎÒ¶¼Òª±£´æµ½ÎļþÖÐÈ¥£¬È磺
µÚÒ»´Î£ºÔö¼ ......

java½âÎöXMLµÄËÄÖÖ·½·¨

XMLÏÖÔÚÒѾ­³ÉΪһÖÖͨÓõÄÊý¾Ý½»»»¸ñʽ,ËüµÄƽ̨ÎÞ¹ØÐÔ,ÓïÑÔÎÞ¹ØÐÔ,ϵͳÎÞ¹ØÐÔ,¸øÊý¾Ý¼¯³ÉÓë½»»¥´øÀ´Á˼«´óµÄ·½±ã¡£¶ÔÓÚXML±¾ÉíµÄÓ﷨֪ʶÓë¼¼Êõϸ½Ú,ÐèÒªÔĶÁÏà¹ØµÄ¼¼ÊõÎÄÏ×,ÕâÀïÃæ°üÀ¨µÄÄÚÈÝÓÐDOM(Document Object Model),DTD(Document Type Definition),SAX(Simple API for XML),XSD(Xml Schema Definition),XSLT(Exten ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ