My favorites | Sign in
Project Home Downloads Wiki Issues Source
Project Information
Members
Featured
Downloads
Wiki pages
Links

About

XML Builder is a utility that creates simple XML documents using relatively sparse Java code.

It is intended to allow for quick and painless creation of XML documents where you might otherwise be tempted to use concatenated strings, and where you would rather not face the tedium and verbosity of coding with JAXP.

Internally, XML Builder uses JAXP to build a standard W3C Document model (DOM) that you can easily export as a string, or access and manipulate further if you have special requirements.

Created by James Murty (www.jamesmurty.com)

Teaser

This project allows you to easily build XML documents using code structured like the final document. Here is some example code...

XMLBuilder builder = XMLBuilder.create("Projects")
    .e("java-xmlbuilder").a("language", "Java").a("scm","SVN")                    
        .e("Location").a("type", "URL")
            .t("http://code.google.com/p/java-xmlbuilder/")
        .up()
    .up()
    .e("JetS3t").a("language", "Java").a("scm","CVS")
        .e("Location").a("type", "URL")
            .t("http://jets3t.s3.amazonaws.com/index.html");

...that produces this XML document:

<?xml version="1.0" encoding="UTF-8"?>
<Projects>
    <java-xmlbuilder language="Java" scm="SVN">
        <Location type="URL">http://code.google.com/p/java-xmlbuilder/</Location>
    </java-xmlbuilder>
    <JetS3t language="Java" scm="CVS">
        <Location type="URL">http://jets3t.s3.amazonaws.com/index.html</Location>
    </JetS3t>
</Projects>

Getting Started

See the ExampleUsage page.

Download

Download a Jar file containing the latest version of java-xmlbuilder from the download list page.

Maven users can add this project as a dependency with the following additions to a POM.xml file:

<dependencies>
  . . .
  <dependency>
    <groupId>com.jamesmurty.utils</groupId>
    <artifactId>java-xmlbuilder</artifactId>
    <version>0.3</version>
  </dependency>
  . . .
</dependencies>

Kudos

Thanks to Robert Harder for his excellent Base64 encoder implementation: http://iharder.net/base64

Powered by Google Project Hosting