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
<item> <product>Onions</product> <quantity>11</quantity> <price>0.44</price> </item>
Example 2
<?xml version="1.0" encoding="UTF-8"?> <posts> <post category="python"> <title>Python Syntax</title> <published>2022-01-01T11:11:11+11:33</published> </post> <post category="javascript"> <title>JavaScript Plus Operator</title> <published>2022-01-01T18:18:18+18:22</published> </post> <post category="ruby"> <title>Ruby TypeOf</title> <published>2021-11-11T13:13:13+13:22</published> </post> </posts>
Load an XML Document
var xmlhttp = new XMLHttpRequest();
Select all the post title
/posts/post/title
Select title of the first post
/posts/post[1]/title
Get all the post Published Date
/posts/post/published