XPath Tutorial

Contents

https://www.w3schools.com/xml/xpath_intro.asp

XPath is a major element in the XSLT standard.

XPath can be used to navigate through elements and attributes in an XML document.

• XPath stands for XML Path Language
• XPath uses “path like” syntax to identify and navigate nodes in an XML document
• XPath contains over 200 built-in functions
• XPath is a major element in the XSLT standard
• XPath is a W3C recommendation
 1 2 3 4 5 6  //tag[@attribute="value"] //div[@class="price"] (//div[@class="price"])[1] (//div[@class="price"])[2] 

Absolute XPath: Complete Path from Root Element

Relative XPath: You choose Element you want to start from (Use // if you choose Relative XPath)

Example:

  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18   ...
...
...


Relative XPath:

 1  //div[@class="main_menu"]/div[2]/a 

Absolute XPath:

 1  html/body/div/div[3]/div[2]/div[2]/a