SlideShare a Scribd company logo
CIS-189
   XPath provides a logical model for working
    with XML document
   Nodes are used to represent serialized XML
    (in memory)
    ◦ Not all parts of XML document are represented (XML
      declaration, DOCTYPE)
   XPath is used in combination with other tools
    (such as XSLT)
   Legal XPath code is called an expression
    ◦ An XPath expression that return a node set is a
     location path
   Expressions can be absolute and relative
    ◦ Absolute path includes a full definition of how to
      find node
    ◦ Relative path is based on current context (location)
   Root node represents document
    ◦ Can have only one child node (document element)
   Element node represents elements
    ◦ QName (qualified name) includes namespace prefix and
      element name
   Attribute node represent attributes
    ◦ Have name and value
    ◦ Are not represented as child nodes
   Text node represents text value of an element
    ◦ Does not have a name
   Namespace node gives access to the namespace URI
    and prefix
   Comment node
   Processing Instruction Node
   Boolean
    ◦ Written as true() and false()
   String
   Number – floating point values
   Node-set – unordered set
    ◦ Follows document order
   Element node references can be spelled out
    or abbreviated
    /child::movies/child::movie/child::price
    OR
    /movies/movie/price

    ◦ child::nodename can also be written nodename
   Attribute node references
    attribute::attributename
    OR
    @attributename
   self                    following
   child                   following-sibling
   attribute               namespace
   ancestor                parent
   ancestor-or-self        preceding
   descendant              preceding-sibling
   descendent-or-self
   Default axis
   Selects nodes that are immediate nodes of
    context (current) node
   Can use * to refer to all child nodes
<movie>              If context is movie
<title>Up</title>     Location path
<price>4.99</price     child::copy (or
 >                     copy) returns node
<copy>1</copy>         set with both copy
<copy>2</copy>         elements
                      Location path
</movie>
                       child::* (or *)
                       returns node set
                       with title, price, 2
                       copy nodes
   Can use node() to return all child nodes
    including comments, processing instructions,
    and text nodes
   Can return just text nodes using text()
    ◦ Text nodes are unnamed
   Used to select attributes belonging to a
    particular element node
   To return all attributes
    ◦ attribute::*
    ◦ @*
   To return particular attribute
    ◦ attribute::attributename
    ◦ @attributename
   Used to filter node sets
    ◦ Predicate similar to query criteria
   Can use specific values or location references
XML:                              Find 3rd Vehicle:

<vehicles>                        /vehicles/vehicle[2]
   <vehicle model="camaro">
    <year>1967</year>                     (1-based numbering)
    <engine>327 v8</engine>
   </vehicle>                     Find vehicles that are from ‘72:
   <vehicle model="challenger">   /vehicles/vehicle/[year=‘1972’]
    <year>1972</year>
    <engine>383 v8</engine>               (return a node set)
   </vehicle>
   <vehicle model="baja bug">
    <year>multiple</year>
    <engine>1200
  opposing4</engine>
   </vehicle>
</vehicles>

More Related Content

PPTX
Structure & Union in C++
KEY
iPhone Dev: Application Settings and Defaults
ZIP
iPhone Dev: Application Settings and Defaults
PDF
Extending the Xbase Typesystem
PPT
Lecture02
PPTX
Constructor and destructor in oop
PPTX
Constructor and Destructor in c++
PPTX
Constructor and Destructors in C++
Structure & Union in C++
iPhone Dev: Application Settings and Defaults
iPhone Dev: Application Settings and Defaults
Extending the Xbase Typesystem
Lecture02
Constructor and destructor in oop
Constructor and Destructor in c++
Constructor and Destructors in C++

What's hot (19)

PPTX
[OOP - Lec 13,14,15] Constructors / Destructor and its Types
PPTX
INTRODUCTION TO DOM AND DOM TREE
PPTX
Xml dom
PPTX
Introduction to the DOM
PDF
Functional (web) development with Clojure
PPTX
XML Document Object Model (DOM)
PPTX
Constructor in java
PPT
Oop Constructor Destructors Constructor Overloading lecture 2
PPT
Xml dom & sax by bhavsingh maloth
PPT
constructor and destructor-object oriented programming
PPT
Understanding XML DOM
PPT
DOM and SAX
PDF
Ejb3 Struts Tutorial En
PPTX
Pass by value and pass by reference
PPTX
Dom parser
KEY
PPTX
constructors in java ppt
PPTX
[OOP - Lec 20,21] Inheritance
PPTX
Apache Avro and Messaging at Scale in LivePerson
[OOP - Lec 13,14,15] Constructors / Destructor and its Types
INTRODUCTION TO DOM AND DOM TREE
Xml dom
Introduction to the DOM
Functional (web) development with Clojure
XML Document Object Model (DOM)
Constructor in java
Oop Constructor Destructors Constructor Overloading lecture 2
Xml dom & sax by bhavsingh maloth
constructor and destructor-object oriented programming
Understanding XML DOM
DOM and SAX
Ejb3 Struts Tutorial En
Pass by value and pass by reference
Dom parser
constructors in java ppt
[OOP - Lec 20,21] Inheritance
Apache Avro and Messaging at Scale in LivePerson
Ad

Viewers also liked (20)

PPTX
Selenium
PPTX
PDF
Presentazione Testing automatizzato
PPTX
TestNet 2016 - Improving Your Selenium WebDriver Tests
PDF
Pro php refactoring
PPT
Selenium
PPTX
XPath Introduction
PDF
Upgrading to Selenium WebDriver version 3
PDF
Introduction to XPath
PDF
XPath - A practical guide
PDF
Webinar: Selenium WebDriver - Automation Uncomplicated
PPTX
An overview of selenium webdriver
PDF
XPath for web scraping
DOCX
Selenium WebDriver FAQ's
PDF
Selenium webdriver interview questions and answers
PPT
Selenium Concepts
PDF
Selenium Basics Tutorial
PPT
Web Test Automation with Selenium
PPT
Selenium ppt
PDF
Automation Testing using Selenium
Selenium
Presentazione Testing automatizzato
TestNet 2016 - Improving Your Selenium WebDriver Tests
Pro php refactoring
Selenium
XPath Introduction
Upgrading to Selenium WebDriver version 3
Introduction to XPath
XPath - A practical guide
Webinar: Selenium WebDriver - Automation Uncomplicated
An overview of selenium webdriver
XPath for web scraping
Selenium WebDriver FAQ's
Selenium webdriver interview questions and answers
Selenium Concepts
Selenium Basics Tutorial
Web Test Automation with Selenium
Selenium ppt
Automation Testing using Selenium
Ad

Similar to XPath (20)

PPTX
Xml session
PPT
PPTX
X path
PPTX
X path
PPT
Xpath.ppt
PPTX
Structured Strategy: How to Supercharge Your Content Analysis with XML and XPath
PDF
02_Xpath.pdf
PDF
PPTX
Extracting data from xml
PPT
03 x files
PDF
Querring xml with xpath
PPTX
XPath
PPTX
XPATH_XSLT-1.pptx
PPTX
PPTX
chapter 4 web authoring unit 4 xml.pptx
PPTX
Unit-2_XMxvvxvxvxvLccccccccccccccccccccccccccc.pptx
PDF
SXML: S-expression eXtensible Markup Language
PPTX
XML DATABASES in the Master of Engineering
Xml session
X path
X path
Xpath.ppt
Structured Strategy: How to Supercharge Your Content Analysis with XML and XPath
02_Xpath.pdf
Extracting data from xml
03 x files
Querring xml with xpath
XPath
XPATH_XSLT-1.pptx
chapter 4 web authoring unit 4 xml.pptx
Unit-2_XMxvvxvxvxvLccccccccccccccccccccccccccc.pptx
SXML: S-expression eXtensible Markup Language
XML DATABASES in the Master of Engineering

More from Randy Riness @ South Puget Sound Community College (20)

Recently uploaded (20)

PPTX
Spectroscopy.pptx food analysis technology
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPTX
MYSQL Presentation for SQL database connectivity
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Network Security Unit 5.pdf for BCA BBA.
PPTX
Cloud computing and distributed systems.
PDF
Machine learning based COVID-19 study performance prediction
PPT
Teaching material agriculture food technology
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Encapsulation theory and applications.pdf
PDF
Empathic Computing: Creating Shared Understanding
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
Spectroscopy.pptx food analysis technology
NewMind AI Weekly Chronicles - August'25 Week I
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Mobile App Security Testing_ A Comprehensive Guide.pdf
“AI and Expert System Decision Support & Business Intelligence Systems”
Dropbox Q2 2025 Financial Results & Investor Presentation
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Chapter 3 Spatial Domain Image Processing.pdf
Diabetes mellitus diagnosis method based random forest with bat algorithm
MYSQL Presentation for SQL database connectivity
Programs and apps: productivity, graphics, security and other tools
Network Security Unit 5.pdf for BCA BBA.
Cloud computing and distributed systems.
Machine learning based COVID-19 study performance prediction
Teaching material agriculture food technology
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Building Integrated photovoltaic BIPV_UPV.pdf
Encapsulation theory and applications.pdf
Empathic Computing: Creating Shared Understanding
Per capita expenditure prediction using model stacking based on satellite ima...

XPath

  • 2. XPath provides a logical model for working with XML document  Nodes are used to represent serialized XML (in memory) ◦ Not all parts of XML document are represented (XML declaration, DOCTYPE)  XPath is used in combination with other tools (such as XSLT)
  • 3. Legal XPath code is called an expression ◦ An XPath expression that return a node set is a location path  Expressions can be absolute and relative ◦ Absolute path includes a full definition of how to find node ◦ Relative path is based on current context (location)
  • 4. Root node represents document ◦ Can have only one child node (document element)  Element node represents elements ◦ QName (qualified name) includes namespace prefix and element name  Attribute node represent attributes ◦ Have name and value ◦ Are not represented as child nodes  Text node represents text value of an element ◦ Does not have a name  Namespace node gives access to the namespace URI and prefix  Comment node  Processing Instruction Node
  • 5. Boolean ◦ Written as true() and false()  String  Number – floating point values  Node-set – unordered set ◦ Follows document order
  • 6. Element node references can be spelled out or abbreviated /child::movies/child::movie/child::price OR /movies/movie/price ◦ child::nodename can also be written nodename  Attribute node references attribute::attributename OR @attributename
  • 7. self  following  child  following-sibling  attribute  namespace  ancestor  parent  ancestor-or-self  preceding  descendant  preceding-sibling  descendent-or-self
  • 8. Default axis  Selects nodes that are immediate nodes of context (current) node  Can use * to refer to all child nodes
  • 9. <movie> If context is movie <title>Up</title>  Location path <price>4.99</price child::copy (or > copy) returns node <copy>1</copy> set with both copy <copy>2</copy> elements  Location path </movie> child::* (or *) returns node set with title, price, 2 copy nodes
  • 10. Can use node() to return all child nodes including comments, processing instructions, and text nodes  Can return just text nodes using text() ◦ Text nodes are unnamed
  • 11. Used to select attributes belonging to a particular element node  To return all attributes ◦ attribute::* ◦ @*  To return particular attribute ◦ attribute::attributename ◦ @attributename
  • 12. Used to filter node sets ◦ Predicate similar to query criteria  Can use specific values or location references
  • 13. XML: Find 3rd Vehicle: <vehicles> /vehicles/vehicle[2] <vehicle model="camaro"> <year>1967</year> (1-based numbering) <engine>327 v8</engine> </vehicle> Find vehicles that are from ‘72: <vehicle model="challenger"> /vehicles/vehicle/[year=‘1972’] <year>1972</year> <engine>383 v8</engine> (return a node set) </vehicle> <vehicle model="baja bug"> <year>multiple</year> <engine>1200 opposing4</engine> </vehicle> </vehicles>