SlideShare a Scribd company logo
http://www.tutorialspoint.com/xquery/xquery_xpath.htm Copyright © tutorialspoint.com
XQUERY - XPATHXQUERY - XPATH
XQuery is XPath compliant. It uses XPath expressions to restrict the search results on XML
collections. For more details on how to use XPath, see our XPath Tutorial.
Recall the following XPath expression which we have used earlier to get the list of books.
doc("books.xml")/books/book
XPath Examples
We will use the books.xml file and apply XQuery to it.
books.xml
<?xml version="1.0" encoding="UTF-8"?>
<books>
<book category="JAVA">
<title lang="en">Learn Java in 24 Hours</title>
<author>Robert</author>
<year>2005</year>
<price>30.00</price>
</book>
<book category="DOTNET">
<title lang="en">Learn .Net in 24 hours</title>
<author>Peter</author>
<year>2011</year>
<price>40.50</price>
</book>
<book category="XML">
<title lang="en">Learn XQuery in 24 hours</title>
<author>Robert</author>
<author>Peter</author>
<year>2013</year>
<price>50.00</price>
</book>
<book category="XML">
<title lang="en">Learn XPath in 24 hours</title>
<author>Jay Ban</author>
<year>2010</year>
<price>16.50</price>
</book>
</books>
We have given here three versions of an XQuery statement that fulfil the same objective of
displaying the book titles having a price value greater than 30.
XQuery – Version 1
(: read the entire xml document :)
let $books := doc("books.xml")
for $x in $books/books/book
where $x/price > 30
return $x/title
Output
<title lang="en">Learn .Net in 24 hours</title>
<title lang="en">Learn XQuery in 24 hours</title>
XQuery – Version 2
(: read all books :)
let $books := doc("books.xml")/books/book
for $x in $books
where $x/price > 30
return $x/title
Output
<title lang="en">Learn .Net in 24 hours</title>
<title lang="en">Learn XQuery in 24 hours</title>
XQuery – Version 3
(: read books with price > 30 :)
let $books := doc("books.xml")/books/book[price > 30]
for $x in $books
return $x/title
Output
<title lang="en">Learn .Net in 24 hours</title>
<title lang="en">Learn XQuery in 24 hours</title>
Verify the Result
To verify the result, replace the contents of books.xqy (given in the Environment Setup chapter)
with the above XQuery expression and execute the XQueryTester java program.

More Related Content

Similar to Xquery xpath (20)

PDF
Xquery basics tutorial
Divya Bodkhe
 
PPT
03 x files
Baskarkncet
 
PDF
Querying XML: XPath and XQuery
Katrien Verbert
 
PPTX
X path
Sagar Guhe
 
PPTX
X path
Sagar Guhe
 
PPTX
Xquery 131102171402-phpapp01
Harish Bandi
 
PDF
Xquery1
Dr.Saranya K.G
 
PPTX
Xml transformation language
reshmavasudev
 
PPTX
XQuery
Raji Ghawi
 
DOC
X query
xavier john
 
PDF
Querring xml with xpath
Malintha Adikari
 
PPT
X Query for beginner
Nguyen Quang
 
PPT
XML - State of the Art
Jakub Malý
 
PDF
Xpath tutorial
Ashoka Vanjare
 
PPTX
unit 1 adbms _3.pptxvhjvjhvjhvjhvjjvjvjvjvjv
zmulani8
 
PPTX
Introductionto xslt
Kumar
 
PPTX
Xml presentation
Miguel Angel Teheran Garcia
 
PPTX
XML DATABASES in the Master of Engineering
poonkodiraja2806
 
PDF
[3.3] Detection & exploitation of Xpath/Xquery Injections - Boris Savkov
OWASP Russia
 
Xquery basics tutorial
Divya Bodkhe
 
03 x files
Baskarkncet
 
Querying XML: XPath and XQuery
Katrien Verbert
 
X path
Sagar Guhe
 
X path
Sagar Guhe
 
Xquery 131102171402-phpapp01
Harish Bandi
 
Xml transformation language
reshmavasudev
 
XQuery
Raji Ghawi
 
X query
xavier john
 
Querring xml with xpath
Malintha Adikari
 
X Query for beginner
Nguyen Quang
 
XML - State of the Art
Jakub Malý
 
Xpath tutorial
Ashoka Vanjare
 
unit 1 adbms _3.pptxvhjvjhvjhvjhvjjvjvjvjvjv
zmulani8
 
Introductionto xslt
Kumar
 
Xml presentation
Miguel Angel Teheran Garcia
 
XML DATABASES in the Master of Engineering
poonkodiraja2806
 
[3.3] Detection & exploitation of Xpath/Xquery Injections - Boris Savkov
OWASP Russia
 

More from Ashoka Vanjare (20)

PDF
Tika tutorial
Ashoka Vanjare
 
PDF
Sqlite perl
Ashoka Vanjare
 
PDF
Sqoop tutorial
Ashoka Vanjare
 
PDF
Xml tutorial
Ashoka Vanjare
 
PDF
Xsd tutorial
Ashoka Vanjare
 
PDF
Xslt tutorial
Ashoka Vanjare
 
PDF
Postgresql tutorial
Ashoka Vanjare
 
PDF
Postgresql quick guide
Ashoka Vanjare
 
PDF
Perl tutorial final
Ashoka Vanjare
 
PDF
Perltut
Ashoka Vanjare
 
PDF
Php7 tutorial
Ashoka Vanjare
 
PDF
Mongodb tutorial
Ashoka Vanjare
 
PDF
Maven tutorial
Ashoka Vanjare
 
PDF
Mahout tutorial
Ashoka Vanjare
 
PDF
Learn embedded systems tutorial
Ashoka Vanjare
 
PDF
Learn data structures algorithms tutorial
Ashoka Vanjare
 
PDF
Learn c standard library
Ashoka Vanjare
 
PDF
Learn c programming
Ashoka Vanjare
 
PDF
Json tutorial
Ashoka Vanjare
 
PDF
Json perl example
Ashoka Vanjare
 
Tika tutorial
Ashoka Vanjare
 
Sqlite perl
Ashoka Vanjare
 
Sqoop tutorial
Ashoka Vanjare
 
Xml tutorial
Ashoka Vanjare
 
Xsd tutorial
Ashoka Vanjare
 
Xslt tutorial
Ashoka Vanjare
 
Postgresql tutorial
Ashoka Vanjare
 
Postgresql quick guide
Ashoka Vanjare
 
Perl tutorial final
Ashoka Vanjare
 
Php7 tutorial
Ashoka Vanjare
 
Mongodb tutorial
Ashoka Vanjare
 
Maven tutorial
Ashoka Vanjare
 
Mahout tutorial
Ashoka Vanjare
 
Learn embedded systems tutorial
Ashoka Vanjare
 
Learn data structures algorithms tutorial
Ashoka Vanjare
 
Learn c standard library
Ashoka Vanjare
 
Learn c programming
Ashoka Vanjare
 
Json tutorial
Ashoka Vanjare
 
Json perl example
Ashoka Vanjare
 
Ad

Recently uploaded (20)

PPTX
MT Chapter 1.pptx- Magnetic particle testing
ABCAnyBodyCanRelax
 
PDF
Biodegradable Plastics: Innovations and Market Potential (www.kiu.ac.ug)
publication11
 
PPTX
22PCOAM21 Session 1 Data Management.pptx
Guru Nanak Technical Institutions
 
PPTX
Online Cab Booking and Management System.pptx
diptipaneri80
 
PDF
Zero carbon Building Design Guidelines V4
BassemOsman1
 
PPTX
ENSA_Module_7.pptx_wide_area_network_concepts
RanaMukherjee24
 
PDF
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
DOCX
SAR - EEEfdfdsdasdsdasdasdasdasdasdasdasda.docx
Kanimozhi676285
 
PPTX
Introduction to Fluid and Thermal Engineering
Avesahemad Husainy
 
PDF
EVS+PRESENTATIONS EVS+PRESENTATIONS like
saiyedaqib429
 
PPTX
filteration _ pre.pptx 11111110001.pptx
awasthivaibhav825
 
PPTX
cybersecurityandthe importance of the that
JayachanduHNJc
 
PDF
Construction of a Thermal Vacuum Chamber for Environment Test of Triple CubeS...
2208441
 
PDF
SG1-ALM-MS-EL-30-0008 (00) MS - Isolators and disconnecting switches.pdf
djiceramil
 
PPTX
quantum computing transition from classical mechanics.pptx
gvlbcy
 
PDF
AI-Driven IoT-Enabled UAV Inspection Framework for Predictive Maintenance and...
ijcncjournal019
 
PDF
Jual GPS Geodetik CHCNAV i93 IMU-RTK Lanjutan dengan Survei Visual
Budi Minds
 
PDF
Machine Learning All topics Covers In This Single Slides
AmritTiwari19
 
PDF
All chapters of Strength of materials.ppt
girmabiniyam1234
 
PDF
4 Tier Teamcenter Installation part1.pdf
VnyKumar1
 
MT Chapter 1.pptx- Magnetic particle testing
ABCAnyBodyCanRelax
 
Biodegradable Plastics: Innovations and Market Potential (www.kiu.ac.ug)
publication11
 
22PCOAM21 Session 1 Data Management.pptx
Guru Nanak Technical Institutions
 
Online Cab Booking and Management System.pptx
diptipaneri80
 
Zero carbon Building Design Guidelines V4
BassemOsman1
 
ENSA_Module_7.pptx_wide_area_network_concepts
RanaMukherjee24
 
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
SAR - EEEfdfdsdasdsdasdasdasdasdasdasdasda.docx
Kanimozhi676285
 
Introduction to Fluid and Thermal Engineering
Avesahemad Husainy
 
EVS+PRESENTATIONS EVS+PRESENTATIONS like
saiyedaqib429
 
filteration _ pre.pptx 11111110001.pptx
awasthivaibhav825
 
cybersecurityandthe importance of the that
JayachanduHNJc
 
Construction of a Thermal Vacuum Chamber for Environment Test of Triple CubeS...
2208441
 
SG1-ALM-MS-EL-30-0008 (00) MS - Isolators and disconnecting switches.pdf
djiceramil
 
quantum computing transition from classical mechanics.pptx
gvlbcy
 
AI-Driven IoT-Enabled UAV Inspection Framework for Predictive Maintenance and...
ijcncjournal019
 
Jual GPS Geodetik CHCNAV i93 IMU-RTK Lanjutan dengan Survei Visual
Budi Minds
 
Machine Learning All topics Covers In This Single Slides
AmritTiwari19
 
All chapters of Strength of materials.ppt
girmabiniyam1234
 
4 Tier Teamcenter Installation part1.pdf
VnyKumar1
 
Ad

Xquery xpath

  • 1. http://www.tutorialspoint.com/xquery/xquery_xpath.htm Copyright © tutorialspoint.com XQUERY - XPATHXQUERY - XPATH XQuery is XPath compliant. It uses XPath expressions to restrict the search results on XML collections. For more details on how to use XPath, see our XPath Tutorial. Recall the following XPath expression which we have used earlier to get the list of books. doc("books.xml")/books/book XPath Examples We will use the books.xml file and apply XQuery to it. books.xml <?xml version="1.0" encoding="UTF-8"?> <books> <book category="JAVA"> <title lang="en">Learn Java in 24 Hours</title> <author>Robert</author> <year>2005</year> <price>30.00</price> </book> <book category="DOTNET"> <title lang="en">Learn .Net in 24 hours</title> <author>Peter</author> <year>2011</year> <price>40.50</price> </book> <book category="XML"> <title lang="en">Learn XQuery in 24 hours</title> <author>Robert</author> <author>Peter</author> <year>2013</year> <price>50.00</price> </book> <book category="XML"> <title lang="en">Learn XPath in 24 hours</title> <author>Jay Ban</author> <year>2010</year> <price>16.50</price> </book> </books> We have given here three versions of an XQuery statement that fulfil the same objective of displaying the book titles having a price value greater than 30. XQuery – Version 1 (: read the entire xml document :) let $books := doc("books.xml") for $x in $books/books/book where $x/price > 30 return $x/title
  • 2. Output <title lang="en">Learn .Net in 24 hours</title> <title lang="en">Learn XQuery in 24 hours</title> XQuery – Version 2 (: read all books :) let $books := doc("books.xml")/books/book for $x in $books where $x/price > 30 return $x/title Output <title lang="en">Learn .Net in 24 hours</title> <title lang="en">Learn XQuery in 24 hours</title> XQuery – Version 3 (: read books with price > 30 :) let $books := doc("books.xml")/books/book[price > 30] for $x in $books return $x/title Output <title lang="en">Learn .Net in 24 hours</title> <title lang="en">Learn XQuery in 24 hours</title> Verify the Result To verify the result, replace the contents of books.xqy (given in the Environment Setup chapter) with the above XQuery expression and execute the XQueryTester java program.