XPath Examples

Last Updated On Friday 6th May 2022

example xpath

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
  • It uses path like syntax to identify and navigate nodes in an XML document
  • XPath contains over 200 built-in functions
  • XPath uses path expressions to select nodes or node-sets in an XML document.
  • It’s format for storing and exchanging data.
  • As I Said above it includes over 200 built-in functions.
  • There are functions for string values, numeric values, booleans, date and time comparison, node manipulation, sequence manipulation, and much more.

Example 1


Example 2

	<?xml version="1.0" encoding="UTF-8"?>
  <post category="python">
    <title>Python Syntax</title>
  <post category="javascript">
    <title>JavaScript Plus Operator</title>
  <post category="ruby">
    <title>Ruby TypeOf</title>

Load an XML Document

	var xmlhttp = new XMLHttpRequest();

Select all the post title


Select title of the first post


Get all the post Published Date