apache > xmlbeans.apache.org

Welcome to XMLBeans

What is XMLBeans?

XMLBeans is a technology for accessing XML by binding it to Java types. XMLBeans provides several ways to get at the XML, including:

  • Through XML schema that has been compiled to generate Java types that represent schema types. In this way, you can access instances of the schema through JavaBeans-style accessors after the fashion of "getFoo" and "setFoo".

    The XMLBeans API also allows you to reflect into the XML schema itself through an XML Schema Object model.

  • A cursor model through which you can traverse the full XML infoset.
  • Support for XML DOM.

For a more complete introduction, see the XMLBeans Overview or Getting Started With XMLBeans.

For more details on XMLBeans see the XMLBeans Wiki pages or the XMLBeans documentation (the Documentation tab on this website).

Release: Apache XMLBeans 2.6.0 (August 14, 2012)

Latest release files are available.

Few of the improvements in this release (for a more complete list of changes see CHANGES.txt).

  • Add new xml option CopyUseNewSynchronizationDomain used for copy. This fixes the scenario when copy and access (ex. selectPath) are used in a multithreading environment.
  • Entitize \r when not in pretty print, this helps with maintainig \r entities
  • Update durations to latest spec.
  • Fix for compiling schema that contains complex type with simple content that has facets defined in the base simple type
  • Introducing a default maximum entity replacement limit of 10kb, it can be controled by using the option XmlOptions.setLoadEntityBytesLimit.
  • Added multiple entry points and refactored code for xsd2inst code.
  • Many synchronization and stability bug fixes

Note: Starting with XmlBeans 2.6.0, binary files are compatible with JDK1.6. Sources are still compatible with JDK 1.4. When using JDK 1.4, xmlbeans-qname.jar is required on classpath of your application alongside xbean.jar.

Getting Started

Start off with your own stuff.

If you want to get right to it with your own XML schema and instance, follow these basic steps:

  1. Install XMLBeans.
  2. Compile your schema. Use scomp to compile the schema, generating and jarring Java types. For example, to create a employeeschema.jar from an employeesschema.xsd file:
    scomp -out employeeschema.jar employeeschema.xsd
  3. Write code. With the generated JAR on your classpath, write code to bind an XML instance to the Java types representing your schema. Here's an example that would use types generated from an employees schema:
    File xmlFile = new File("c:\employees.xml"); 
    // Bind the instance to the generated XMLBeans types.
    EmployeesDocument empDoc = 
    // Get and print pieces of the XML instance.
    Employees emps = empDoc.getEmployees(); 
    Employee[] empArray = emps.getEmployeeArray(); 
    for (int i = 0; i < empArray.length; i++) 

Read a tutorial.

Read our tutorial to get a sense of XMLBeans basics.

Read documentation and other information.

On our documentation page, you'll find links to several topics that describe XMLBeans features and how to use them. You'll also find links to Javadoc reference on the XMLBeans API.

You can also check out the FAQ, which is updated with new answers as they're needed.

Don't forget the XMLBeans Wiki, which collects lots of valuable information.

Check out the samples.

Many of the XMLBeans features are illustrated in our samples.