Learning XPath

Go back to tutorial

What is XPath (XML Path Language)?

Learning XPath

Learning XPath

XPath (XML Path Language) is a query language for selecting nodes from an XML document. In addition, you may use XPath to compute values such as strings, numbers, or Boolean values from the content of an XML document.

As a matter of fact XPath language is based on a tree representation of the XML document. It provides the ability to navigate around the tree, thereby selecting nodes by a variety of criteria. The most important kind of expression in XPath is a location path. A location path consists of a sequence of location steps. Further, each location step has three components an axis, a node test, and zero or more predicates.

XPath expression is evaluated with respect to a context node.

  • Axis Specifier such as ‘child’ or ‘descendant’ specifies the direction to navigate from the context node.
  • Node test and the predicate are used to filter the nodes specified by the axis specifier.

Types of XPath (XML Path Language) Syntax

The XPath syntax comes in two ways –

  1. Abbreviated syntax, is more compact and allows XPaths to be written and read easily using intuitive and, in many cases, familiar characters and constructs.
  2. Full syntax is more verbose, but allows for more options to be specified, and is more descriptive if read carefully. Also referred as expanded syntax.

Boost your chances for better job opportunities. Practice and Prepare for Mobile Testing (Appium) Exam Now!

Go back to tutorial

Get industry recognized certification – Contact us

Menu