Java Examples

This is the Java example section of the XML Tutorial site. The examples are organized as follows:

  • XML & Java
  • XPATH & Java
  • XSLT & Java

This is an ongoing project - Be sure to follow our site as we are constantly adding new content just for you! If you have a special request, contact us and let us know!

Latest Additions

  • How to create a XML document - A newly created, in-memory, XML document is sometimes necessary for ad-hoc data manipulation and / or document generation.
  • How to read an XML attribute value - There are a number of methods to read an XML attribute value. We present two common methods here: Locate and read an element value using the XML DOM; or Locate and read an element using XPATH expressions.
  • How To Save Java Objects As XML - Integration between disparate systems sometimes require a mapping exercise between the protocol XML and the POJO you are using for data storage processing. Java defines a comprehensive binding framework – JAXB –  which can be used for this task.