Skip to main content

Xpath




Xpath concept

What is Xpath?

The Xpath language is the system used to navigate and consult the items and attributes contained in the structure of an XML document. But, to know the concept of Xpath (XML Path Language), andIt is important to first clarify the meaning of XML eXtensible Markup Language, whose translation is extensible markup language.

For it uses a criteria syntax and functions that allow you to perform calculations, comparisons, and identify nodes. Arguably, XPath works in a similar way to the formula editor in Excel, extracting information from a document to make calculations.

Let's say you want to mark important dates on a calendar, so you decide to use symbols and colors to mark and differentiate between birthdays, doctor's appointments, and bill due dates. In the same way, the XML language uses tags to differentiate the types of data it stores and transports in files. This language was developed by the World Wide Web Consortium W3C and comes from another one invented by IBM in the 70s, called GML.

What is Xpath for

XPath is used for programmers can define advanced search criteria and specific calculations, using a simple syntax, but quite effective.

Contains a library of 100 standard functions, which allow operations to be carried out for the handling of strings, numerical operations, date comparisons ... and so on.

XPath it is not an independent language, because it is used in combination with XSLT (eXtensible Stylesheet Language for Transformations) or language that allows applying a transformation to an XML document.

Xpath examples

For XPath, an XML document is like a tree, which is made up of two concepts. On the one hand, the representation of different types of nodes; on the other, the possible relationships between these nodes.

There are various types of nodes, the most basic are called:

  • Element Node.
  • Attribute node.
  • Text Node.
  • Root node.
  • Root element.
  • Atomic values.

The root node of the tree contains the root element of the document. All XML documents have a root node that indicates the start of the document, on which all other nodes in the document depend.

More information on Xpath

To learn more about other programming languages and related topics, we suggest the following posts:

R Marketing Digital