Home » Core Java » xml » XPath

XPath

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 »

XPath concat Example

We studied about Xpath normalize-space() method in the previous example. In this example, we will study how the concat(String s1, String s2, String... s3) method works. The XPath-concat method works similar to the String#concat method. It joins two or more strings into a single string. The argument strings maybe two or more static strings and/or they may be two or ...

Read More »

XPath normalize-space example

In this example, we will talk about the normalize-space method in XPath. The normalize-space(String s) method is used to normalize a string i.e. to remove any leading or trailing spaces from the string s passed as parameter to the XPath function. We will look at a few examples at the examples to see how the normalize-space method works in an ...

Read More »

Want to take your Java skills to the next level?

Grab our programming books for FREE!

Here are some of the eBooks you will get:

  • Spring Interview QnA
  • Multithreading & Concurrency QnA
  • JPA Minibook
  • JVM Troubleshooting Guide
  • Advanced Java
  • Java Interview QnA
  • Java Design Patterns