SlideShare a Scribd company logo
XPath is used to navigate through elements and attributes in an XML document.
XPath is a major element in XSLT standard - and XQuery and XPointer are both
built on XPath expressions
XPath is a language for finding information in an XML document.
• XPath is a syntax for defining parts of an XML document
• XPath uses path expressions to navigate in XML documents
XPath Syntax
XPath uses path expressions to select nodes or node-sets in an XML
document. The node is selected by following a path or steps.
The XML Example Document
We will use the following XML document in the examples below.
<?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:
Expression Description
nodename Selects all child nodes of the named 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
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 Selects the root element bookstore
Note: If the path starts with a slash ( / ) it always
represents an absolute path to an element!
bookstore/book Selects all book elements that are children of bookstore
//book Selects all book elements no matter where they are in the
document
bookstore//book Selects all book elements that are descendant of the
bookstore element, no matter where they are under the
bookstore element
//@lang Selects all attributes that are named lang
Selecting Unknown Nodes
XPath wildcards can be used to select unknown XML elements.
Wildcard Description
* Matches any element node
@* Matches any attribute node
node() Matches any node of any kind
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
//* Selects all elements in the document
//title[@*] Selects all title elements which have any attribute

More Related Content

PDF
XSLT and XPath - without the pain!
Bertrand Delacretaz
 
PPT
Xpath
Manav Prasad
 
PPTX
XPath
Raji Ghawi
 
PPT
Xpath presentation
Alfonso Gabriel López Ceballos
 
PPTX
XPATH
Sun Technlogies
 
PPTX
XPath Introduction
Stuart Myles
 
XSLT and XPath - without the pain!
Bertrand Delacretaz
 
XPath
Raji Ghawi
 
XPath Introduction
Stuart Myles
 

What's hot (20)

PPT
XML and XPath details
DSK Chakravarthy
 
PPT
XML/XSLT
thinkahead.net
 
PPTX
Extracting data from xml
Kumar
 
PPTX
XSLT presentation
Miguel Angel Teheran Garcia
 
PPT
Session 4
Lại Đức Chung
 
PPT
03 x files
Baskarkncet
 
PPT
Rendering XML Document
yht4ever
 
PPTX
transforming xml using xsl and xslt
Hemant Suthar
 
PPTX
Introductionto xslt
Kumar
 
PPTX
Xslt tutorial
Bijoy Kureekkal
 
PDF
Querying XML: XPath and XQuery
Katrien Verbert
 
PPTX
XSLT
Kamal Acharya
 
PDF
XML Security Using XSLT
Ahmed Muzammil
 
PPTX
Xml transformation language
reshmavasudev
 
PPTX
Intro xml
sana mateen
 
PDF
Python xml processing
Learnbay Datascience
 
PPTX
Web programming xml
Uma mohan
 
PPTX
Xml basics
Kumar
 
PPT
00 introduction
Baskarkncet
 
PPT
Cs511 data-extraction
Borseshweta
 
XML and XPath details
DSK Chakravarthy
 
XML/XSLT
thinkahead.net
 
Extracting data from xml
Kumar
 
XSLT presentation
Miguel Angel Teheran Garcia
 
03 x files
Baskarkncet
 
Rendering XML Document
yht4ever
 
transforming xml using xsl and xslt
Hemant Suthar
 
Introductionto xslt
Kumar
 
Xslt tutorial
Bijoy Kureekkal
 
Querying XML: XPath and XQuery
Katrien Verbert
 
XML Security Using XSLT
Ahmed Muzammil
 
Xml transformation language
reshmavasudev
 
Intro xml
sana mateen
 
Python xml processing
Learnbay Datascience
 
Web programming xml
Uma mohan
 
Xml basics
Kumar
 
00 introduction
Baskarkncet
 
Cs511 data-extraction
Borseshweta
 
Ad

Viewers also liked (19)

PDF
01 HK RTL - Electrician en
Alexander Pfeffer
 
PDF
Feasibility Studies: BTX Manufacturing
Intratec Solutions
 
DOC
Informatica
ainara alvarez
 
PPTX
The day after the course
Shachar Oz
 
DOCX
While.doc
xavier john
 
PPTX
Trabajo tecnologia octure 2
Mateo Paz Quintero
 
PPSX
Торгово-офисный центр в Домодедово
Концерн «АйсРоос»
 
PDF
Feasibility Studies: Biodiesel Manufacturing
Intratec Solutions
 
PDF
Economics of Bisphenol A Production Processes
Intratec Solutions
 
PDF
KING SBC
KING SBC
 
DOCX
Xml material
xavier john
 
DOC
Xsd
xavier john
 
PPTX
ANOIKTO PANEPISTIMIO KYPROU Drastiriotita 1
chrystallacharalampous
 
PPSX
Xsd basics
xavier john
 
PDF
01 HK RTL - Gesellenbrief dt
Alexander Pfeffer
 
PPTX
Presentación1julia
olivatorrejulia
 
DOC
X query
xavier john
 
DOCX
обоснование нирм
elena_lagoda
 
PDF
OpenCms Days 2013 - Outsourcing OpenCms Template Design
Alkacon Software GmbH & Co. KG
 
01 HK RTL - Electrician en
Alexander Pfeffer
 
Feasibility Studies: BTX Manufacturing
Intratec Solutions
 
Informatica
ainara alvarez
 
The day after the course
Shachar Oz
 
While.doc
xavier john
 
Trabajo tecnologia octure 2
Mateo Paz Quintero
 
Торгово-офисный центр в Домодедово
Концерн «АйсРоос»
 
Feasibility Studies: Biodiesel Manufacturing
Intratec Solutions
 
Economics of Bisphenol A Production Processes
Intratec Solutions
 
KING SBC
KING SBC
 
Xml material
xavier john
 
ANOIKTO PANEPISTIMIO KYPROU Drastiriotita 1
chrystallacharalampous
 
Xsd basics
xavier john
 
01 HK RTL - Gesellenbrief dt
Alexander Pfeffer
 
Presentación1julia
olivatorrejulia
 
X query
xavier john
 
обоснование нирм
elena_lagoda
 
OpenCms Days 2013 - Outsourcing OpenCms Template Design
Alkacon Software GmbH & Co. KG
 
Ad

Similar to Xpath (20)

PPTX
X path
Sagar Guhe
 
PPTX
X path
Sagar Guhe
 
PPT
TAppWeb Training Material
Arvie Bernal
 
PDF
A brief overview of XPath - Topic in XML - Web Technologies
SadhuRamakrishnanBal
 
PDF
Xpath.pdf
BalasundaramSr
 
PPT
TAppWeb Training Material
Arvie Bernal
 
PPT
TApp Web training material_rev4
Arvie Bernal
 
PPTX
TApp Documentation
Arvie Bernal
 
PDF
Day2 xslt x_path_xquery
XAVIERCONSULTANTS
 
PPT
C:\fakepath\xsl final
shivpriya
 
PPTX
Xml session
Farag Zakaria
 
PDF
Querring xml with xpath
Malintha Adikari
 
PPT
Learning XSLT
Overdue Books LLC
 
PPTX
XPATH_XSLT-1.pptx
BalasundaramSr
 
PPT
Xml and DTD's
Swati Parmar
 
PPT
Xml and Co.
Findik Dervis
 
PPT
Week 12 xml and xsl
hapy
 
PDF
02_Xpath.pdf
Prerak10
 
PPT
XPath - XML Path Language
yht4ever
 
X path
Sagar Guhe
 
X path
Sagar Guhe
 
TAppWeb Training Material
Arvie Bernal
 
A brief overview of XPath - Topic in XML - Web Technologies
SadhuRamakrishnanBal
 
Xpath.pdf
BalasundaramSr
 
TAppWeb Training Material
Arvie Bernal
 
TApp Web training material_rev4
Arvie Bernal
 
TApp Documentation
Arvie Bernal
 
Day2 xslt x_path_xquery
XAVIERCONSULTANTS
 
C:\fakepath\xsl final
shivpriya
 
Xml session
Farag Zakaria
 
Querring xml with xpath
Malintha Adikari
 
Learning XSLT
Overdue Books LLC
 
XPATH_XSLT-1.pptx
BalasundaramSr
 
Xml and DTD's
Swati Parmar
 
Xml and Co.
Findik Dervis
 
Week 12 xml and xsl
hapy
 
02_Xpath.pdf
Prerak10
 
XPath - XML Path Language
yht4ever
 

More from xavier john (20)

PPT
Unix day4 v1.3
xavier john
 
PPT
Unix day3 v1.3
xavier john
 
PPT
Unix day2 v1.3
xavier john
 
TXT
Interview questions
xavier john
 
DOCX
Xavier async callback_fault
xavier john
 
DOCX
Custom faultpolicies
xavier john
 
DOCX
All adapterscommonproperties
xavier john
 
DOCX
Custom faultpolicies
xavier john
 
DOCX
Oracle business rules
xavier john
 
DOCX
Soap.doc
xavier john
 
DOCX
Soa installation
xavier john
 
PPT
Vx vm
xavier john
 
DOCX
Webservices
xavier john
 
DOC
Xslt
xavier john
 
DOCX
All adapterscommonproperties
xavier john
 
DOCX
All adapterscommonproperties
xavier john
 
DOCX
Jmsconsume
xavier john
 
DOCX
oracle soa Examples
xavier john
 
DOCX
Deployment document
xavier john
 
DOCX
Database adapter
xavier john
 
Unix day4 v1.3
xavier john
 
Unix day3 v1.3
xavier john
 
Unix day2 v1.3
xavier john
 
Interview questions
xavier john
 
Xavier async callback_fault
xavier john
 
Custom faultpolicies
xavier john
 
All adapterscommonproperties
xavier john
 
Custom faultpolicies
xavier john
 
Oracle business rules
xavier john
 
Soap.doc
xavier john
 
Soa installation
xavier john
 
Webservices
xavier john
 
All adapterscommonproperties
xavier john
 
All adapterscommonproperties
xavier john
 
Jmsconsume
xavier john
 
oracle soa Examples
xavier john
 
Deployment document
xavier john
 
Database adapter
xavier john
 

Recently uploaded (20)

PDF
lesson-2-rules-of-netiquette.pdf.bshhsjdj
jasmenrojas249
 
PPTX
Can You Build Dashboards Using Open Source Visualization Tool.pptx
Varsha Nayak
 
PDF
Applitools Platform Pulse: What's New and What's Coming - July 2025
Applitools
 
PPTX
Maximizing Revenue with Marketo Measure: A Deep Dive into Multi-Touch Attribu...
bbedford2
 
PDF
Salesforce Implementation Services Provider.pdf
VALiNTRY360
 
PDF
Immersive experiences: what Pharo users do!
ESUG
 
PDF
Using licensed Data Loss Prevention (DLP) as a strategic proactive data secur...
Q-Advise
 
PDF
Key Features to Look for in Arizona App Development Services
Net-Craft.com
 
PDF
WatchTraderHub - Watch Dealer software with inventory management and multi-ch...
WatchDealer Pavel
 
PDF
MiniTool Power Data Recovery Crack New Pre Activated Version Latest 2025
imang66g
 
PDF
Download iTop VPN Free 6.1.0.5882 Crack Full Activated Pre Latest 2025
imang66g
 
PDF
On Software Engineers' Productivity - Beyond Misleading Metrics
Romén Rodríguez-Gil
 
DOCX
Can You Build Dashboards Using Open Source Visualization Tool.docx
Varsha Nayak
 
PDF
What to consider before purchasing Microsoft 365 Business Premium_PDF.pdf
Q-Advise
 
PPTX
GALILEO CRS SYSTEM | GALILEO TRAVEL SOFTWARE
philipnathen82
 
PDF
vAdobe Premiere Pro 2025 (v25.2.3.004) Crack Pre-Activated Latest
imang66g
 
PDF
Bandai Playdia The Book - David Glotz
BluePanther6
 
PPTX
Contractor Management Platform and Software Solution for Compliance
SHEQ Network Limited
 
PPTX
Web Testing.pptx528278vshbuqffqhhqiwnwuq
studylike474
 
PDF
Protecting the Digital World Cyber Securit
dnthakkar16
 
lesson-2-rules-of-netiquette.pdf.bshhsjdj
jasmenrojas249
 
Can You Build Dashboards Using Open Source Visualization Tool.pptx
Varsha Nayak
 
Applitools Platform Pulse: What's New and What's Coming - July 2025
Applitools
 
Maximizing Revenue with Marketo Measure: A Deep Dive into Multi-Touch Attribu...
bbedford2
 
Salesforce Implementation Services Provider.pdf
VALiNTRY360
 
Immersive experiences: what Pharo users do!
ESUG
 
Using licensed Data Loss Prevention (DLP) as a strategic proactive data secur...
Q-Advise
 
Key Features to Look for in Arizona App Development Services
Net-Craft.com
 
WatchTraderHub - Watch Dealer software with inventory management and multi-ch...
WatchDealer Pavel
 
MiniTool Power Data Recovery Crack New Pre Activated Version Latest 2025
imang66g
 
Download iTop VPN Free 6.1.0.5882 Crack Full Activated Pre Latest 2025
imang66g
 
On Software Engineers' Productivity - Beyond Misleading Metrics
Romén Rodríguez-Gil
 
Can You Build Dashboards Using Open Source Visualization Tool.docx
Varsha Nayak
 
What to consider before purchasing Microsoft 365 Business Premium_PDF.pdf
Q-Advise
 
GALILEO CRS SYSTEM | GALILEO TRAVEL SOFTWARE
philipnathen82
 
vAdobe Premiere Pro 2025 (v25.2.3.004) Crack Pre-Activated Latest
imang66g
 
Bandai Playdia The Book - David Glotz
BluePanther6
 
Contractor Management Platform and Software Solution for Compliance
SHEQ Network Limited
 
Web Testing.pptx528278vshbuqffqhhqiwnwuq
studylike474
 
Protecting the Digital World Cyber Securit
dnthakkar16
 

Xpath

  • 1. XPath is used to navigate through elements and attributes in an XML document. XPath is a major element in XSLT standard - and XQuery and XPointer are both built on XPath expressions XPath is a language for finding information in an XML document. • XPath is a syntax for defining parts of an XML document • XPath uses path expressions to navigate in XML documents XPath Syntax XPath uses path expressions to select nodes or node-sets in an XML document. The node is selected by following a path or steps. The XML Example Document We will use the following XML document in the examples below. <?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: Expression Description nodename Selects all child nodes of the named node
  • 2. / 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 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 Selects the root element bookstore Note: If the path starts with a slash ( / ) it always represents an absolute path to an element! bookstore/book Selects all book elements that are children of bookstore //book Selects all book elements no matter where they are in the document bookstore//book Selects all book elements that are descendant of the bookstore element, no matter where they are under the bookstore element //@lang Selects all attributes that are named lang Selecting Unknown Nodes XPath wildcards can be used to select unknown XML elements. Wildcard Description * Matches any element node @* Matches any attribute node node() Matches any node of any kind 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
  • 3. //* Selects all elements in the document //title[@*] Selects all title elements which have any attribute