Home » Core Java » xml

xml

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 »

JAXB Schema Validation Example

In this example, we shall learn how to validate XML against schema using JAXB. Here, we are talking about validating XML against XSD. Validation in context here is the process of verifying that an XML document meets all the constraints expressed in the schema or XSD. JAXB provides functions for validation during unmarshalling but not during marshalling. Let’s understand this ...

Read More »

JAXB: Generate Classes from XSD

In this tutorial, we shall learn generating classes from XML Schema Design (XSD) using JAXB. This can be achieved using JAXB binding compiler XJC command. XJC is included in the bin directory in the JDK starting with Java SE 6. 1. Requirements To see this example in action, following is the minimum requirement: JDK 6 (Java SE 6) or later ...

Read More »

JAXB Binding Example

JAXB stands for Java Architecture for XML Binding. JAXB provides convenient way to bind XML schemas and Java representations, making it easy for developers to work with XML data and its processing in Java based applications. To help with this, JAXB provides methods for unmarshalling XML instance documents into Java content trees, and then marshalling Java content trees back into ...

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 »

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