XmlBuilder
is a tool for declarative construction of XML.See: Description
Class | Description |
---|---|
AttributeNode |
Holds an attribute, which may or may not be namespaced.
|
CommentNode |
Holds a comment.
|
ElementNode |
The primary class for building XML trees and converting them to different
JAXP-centric forms.
|
Node |
A lightweight counterpart of a DOM
Node , focused on creation
rather than manipulation. |
PINode |
Holds a processing instruction.
|
TextNode |
Holds element content.
|
XmlBuilder |
A tool for building XML, avoiding the mistakes of simple text output and
the hassle of the DOM API.
|
Exception | Description |
---|---|
XmlBuilderException |
This exception is used both to report errors directly from the
XmlBuilder code, as well as to wrap exceptions thrown from called code. |
XmlBuilder
is a tool for declarative construction of XML.
It was originally created to generate XML for unit tests, but is useful
wherever you want to construct XML documents with minimal code and a
low memory footprint.
The two classes of interest are ElementNode
and XmlBuilder
: the former contains public
methods for transforming a tree into various representations, while the latter
contains static methods for building such a tree:
import static net.sf.practicalxml.builder.XmlBuilder.*; // ... ElementNode root = element("root", element("child1", text("this is some <text>")), element("child2", attribute("foo", "bar"), attribute("baz", "biff")), element("http::www.example.com/foo", "ns:child3")); Document dom = root.toDOM(); String out = root.toString();