XQuery ÊõÓï
ÔÚ XQuery ÖУ¬ÓÐÆßÖÖ½Úµã£ºÔªËØ¡¢ÊôÐÔ¡¢Îı¾¡¢ÃüÃû¿Õ¼ä¡¢´¦ÀíÖ¸Áî¡¢×¢ÊÍ¡¢ÒÔ¼°Îĵµ½Úµã£¨»ò³ÆÎª¸ù½Úµã£©¡£
XQuery ÊõÓï
½Úµã
ÔÚ XQuery ÖУ¬ÓÐÆßÖÖ½Úµã£ºÔªËØ¡¢ÊôÐÔ¡¢Îı¾¡¢ÃüÃû¿Õ¼ä¡¢´¦ÀíÖ¸Áî¡¢×¢ÊÍ¡¢ÒÔ¼°Îĵµ£¨¸ù£©½Úµã¡£XML ÎĵµÊDZ»×÷Ϊ½ÚµãÊ÷À´¶Ô´ýµÄ¡£Ê÷µÄ¸ù±»³ÆÎªÎĵµ½Úµã»òÕ߸ù½Úµã¡£
Çë¿´ÏÂÃæµÄ XML Îĵµ£º
<?xml version="1.0" encoding="ISO-8859-1"?> <bookstore> <book> <title lang="en">Harry Potter</title> <author>J K. Rowling</author> <year>2005</year> <price>29.99</price> </book> </bookstore>
ÉÏÃæµÄ XML ÎĵµÖеĽڵãÀý×Ó£º
<bookstore> £¨Îĵµ½Úµã£© <author>J K. Rowling</author> £¨ÔªËؽڵ㣩 lang="en" £¨ÊôÐԽڵ㣩
»ù±¾Öµ£¨»ò³ÆÔ×ÓÖµ£¬Atomic value£©
»ù±¾ÖµÊÇÎÞ¸¸»òÎÞ×ӵĽڵ㡣
»ù±¾ÖµµÄÀý×Ó£º
J K. Rowling "en"
씀ÏîÄ¿ÊÇ»ù±¾Öµ»òÕ߽ڵ㡣
½Úµã¹ØÏµ
¸¸£¨Parent£©
ÿ¸öÔªËØÒÔ¼°ÊôÐÔ¶¼ÓÐÒ»¸ö¸¸¡£
ÔÚÏÂÃæµÄÀý×ÓÖУ¬book ÔªËØÊÇ title¡¢author¡¢year ÒÔ¼° price ÔªËØµÄ¸¸£º
<book> <title>Harry Potter</title> <author>J K. Rowling</author> <year>2005</year> <price>29.99</price> </book>
×Ó£¨Children£©
½ÚµãÔªËØ¿ÉÓÐÁã¸ö¡¢Ò»¸ö»ò¶à¸ö×Ó¡£
ÔÚÏÂÃæµÄÀý×ÓÖУ¬title¡¢author¡¢year ÒÔ¼° price ÔªËØ¶¼ÊÇ book ÔªËØµÄ×Ó£º
<book> <title>Harry Potter</title> <author>J K. Rowling</author> <year>2005</year> <price>29.99</price> </book>
ͬ°û£¨Sibling£©
ÓµÓÐÏàͬµÄ¸¸µÄ½Úµã¡£
ÔÚÏÂÃæµÄÀý×ÓÖУ¬title¡¢author¡¢year ÒÔ¼° price ÔªËØ¶¼ÊÇͬ°û£º
<book> <title>Harry Potter</title> <author>J K. Rowling</author> <year>2005</year> <price>29.99</price> </book>
Ïȱ²£¨Ancestor£©
ij½ÚµãµÄ¸¸¡¢¸¸µÄ¸¸£¬µÈµÈ¡£
ÔÚÏÂÃæµÄÀý×ÓÖУ¬title ÔªËØµÄÏȱ²ÊÇ book ÔªËØºÍ bookstoreÔªËØ£º
<bookstore> <book> <title>Harry Potter</title> <author>J K. Rowling</author> <year>2005</year> <price>29.99</price> </book> </bookstore>
ºó´ú£¨Descendant£©
ij¸ö½ÚµãµÄ×Ó£¬×ÓµÄ×Ó£¬µÈµÈ¡£
ÔÚÏÂÃæµÄÀý×ÓÖУ¬bookstore µÄºó´úÊÇ book¡¢title¡¢author¡¢year ÒÔ¼° priceÔªËØ£º
<bookstore> <book> <title>Harry Potter</title> <author>J K. Rowling</author> <year>2005</year> <price>29.99</price> </book> </bookstore>