Home » Core Java » xml » XPath (page 2)

XPath

XPath XSLT Tutorial

In this article we will learn how to use XPath in XSLT. XPath stands for XML Path Language. It is a W3C recommendation. It uses ‘path like’ syntax to identify and navigate nodes in an XML document. 1. Introduction XPath can be used to navigate through elements and attributes in an XML document. XPath contains over 200 built-in functions. There are functions for ...

Read More »

Java XPath Using SAX Example

1. Introduction XPath is used to retrieve and interpret information represented in XML files using either a DOM or SAX parser. * DOM – Document Object Model – This popular class of parsers read the entire XML file and construct the DOM in memory. Since the DOM is memory resident, evaluation of the XPath expressions is faster. * SAX – ...

Read More »

Java XPath Performance Tips

1. Introduction This is the third article in a series dealing with using XPath within a Java application. This article focuses attention on tips for improving XPath performance. The first two articles were: A Java XPath Best Practices Tutorial https://examples.javacodegeeks.com/core-java/xpath-best-practices-tutorial/ Which showed how to setup and evaluate XPath expressions using Java. Java XPath Examples https://examples.javacodegeeks.com/core-java/xml/xpath/java-xpath-examples/ Which explored XPath syntax and ...

Read More »

Java XPath Examples

1. Introduction The previous article, Java XPath Best Practices Tutorial (https://examples.javacodegeeks.com/core-java/xpath-best-practices-tutorial/), explored how to set up a Java application to create a DOM (Document Object Model) document using a DOM parser to read an XML file; and an XPath object to evaluate XPath expressions as applied to the DOM. This article dives into how to construct XPath expressions. Starting with ...

Read More »

XPath parent node example

In the previous example, we introduced the dependant axis specifier. In this example, we shall talk about the ancestor axis in XPath Expression. The ancestor tag is used to select the ancestor of the current node and the ancestor of the ancestor and so on in context of the current node. We will look at a few examples to see ...

Read More »

XPath ancestor example

In this example we will learn how to get the ancestor details of a given node using XPath. We will start with the introduction of XPath – what it is and how to use it, then we will see the working model of the desired functionality. Tools and technologies used in this example are Java 1.6, Maven, Intellij.(Please note you don’t ...

Read More »

XPath descendant example

In this example we shall talk about the Descendant axis specifier in XPath. An axis specifier indicates the direction of navigation in DOM tree of that XML document. This helps in effectively querying the XML document. The Descendant axis selects all the descendants of the current node. The ‘descendant’ refers to the children and grand-children of the current node. We ...

Read More »

XPath innertext selection example

In this example we will learn how to select a node with a given inner text using XPath. We will start with the introduction of XPath – what it is and how to use it, then we will see the working model of inner-text selection. Tools and technologies used in this example are Java 1.6, Intellij. 1. Overview An XPath expression ...

Read More »

XPath count example

In the previous example, we studied how to use the XPath Concat method. In this example, we will see how to use the count method in XPath. The XPath count() method is used to count the number of nodes matching a given XpathExpression. Let’s look at a few examples to understand how the count method works. Consider the XML file ...

Read More »

XPath ends-with example

In this example we will learn how to use the ends-with function of XPath. We will start with the introduction of XPath – what it is and how to use it, then we will see the working model of ends-with function. Tools and technologies used in this example are Java 1.7, Maven, Intellij, Saxon. 1. Overview An XPath expression specifies a pattern ...

Read More »