Home » Core Java » xml

xml

Java XPath Performance DOM vs SAX Example

1. Introduction This article compares the performance of the Java DOM parser distributed with Java and a SAX parser distributed with the Home Edition of Saxon for evaluating various XPath expressions. Typically DOM parsers can evaluate XPath expressions faster than SAX parsers since DOM parsers construct and retain the DOM document in memory when parsing XML data. SAX parsers, on ...

Read More »

Xpath Find by Attribute Value Example

In this article we will learn how to find an xml element using attribute value. We will use IDEA IntelliJ 14.0.2 and Java 8. 1. Introduction XPath is a W3C recommendation. XPath can be used to navigate through elements and attributes in an XML document. XPath is a syntax for defining parts of an XML document. XPath uses path expressions ...

Read More »

Xpath Search by id Example

In this article we will learn how to search for an element (by id) in an XML using XPath. We will make use of IDEA IntelliJ to work on this. I am using IntelliJ 14.0.2 and Java 8. 1. Introduction XPath is a W3C recommendation. XPath stands for XML Path Language. XPath uses path expressions to select nodes or node-sets ...

Read More »

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 »

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 »

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