Sidebar

What is XPATH and is there a good tutorial available online?

0 votes
1.0K views
asked Dec 17, 2013 by gary-t-8719 (14,860 points)

2 Answers

0 votes

XPATH is the "Node Path" syntax used when working with XML message formats.

W3Schools has a good tutorial: http://www.w3schools.com/xpath/

  • XPath is a syntax for defining parts of an XML document
  • XPath uses path expressions to navigate in XML documents
  • XPath contains a library of standard functions
  • XPath is a major element in XSLT
  • XPath is a W3C recommendation

 

answered Jan 23, 2014 by matt-w-2627 (3,220 points)
commented Nov 29, 2016 by jon-t-6024 (560 points)
0 votes
I like to introduce and think of XPATH as an address. Just like an address which can take you to your friends house XPATH provides the computer directions to find specific data within an XML document. Let's look at a simple XML document that is used to calogue books. In the XML document below there are two books One for Harry Potter and the other for Learning XML. If I wanted to reference or get the specfic data about one of these books I would use an XPATH to do so. Below are some example XPATHs referenceing different data elements about the books.
 
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<bookstore>
   <book>
      <title lang="eng">Harry Potter</title>
      <price>29.99</price>
   </book>
   <book>
      <title lang="span">Learning XML</title>
      <price>39.95</price>
   </book>
</bookstore>
 
  • /bookstore/book[1]                   - Reference the first book "Harry Potter"
  • //title[@lang]                             - Reference the languange of the Harry Potter book "english"
  • /bookstore/book[price>35.00]  - Reference all books with a price greater than $35.00 "Learning XML".

To learn more about XPATH W3Schools has a good tutorial: http://www.w3schools.com/xpath/default.asp

 

answered Jul 7, 2014 by gary-t-8719 (14,860 points)
edited Jul 7, 2014 by gary-t-8719
...