JDOM 1.0
JDOM 1.0, introduced in Chapter 8, provides a complete view of an XML document
within a tree model. Although this model is similar to DOM, it is not
as rigid a representation; this allows the content of an
Element
, for example, to be set directly, instead
of setting the value of the child of that Element
.
Additionally, JDOM provides concrete classes rather than interfaces,
allowing direct instantiation of objects rather than through the use
of a factory. SAX and DOM are only used in JDOM for the construction
of a JDOM Document
object from existing XML data,
and are detailed in the org.jdom.input
package.
Package: org.jdom[22]
This package contains the core classes
for JDOM 1.0. These consist of XML objects modeled in Java and a set
of Exception
s that can be thrown when errors
occur.
Attribute
Attribute
defines behavior for an XML attribute,
modeled in Java. Methods allow the user to obtain the value of the
attribute as well as namespace information about the
Attribute
. An instance can be created with the
name of the attribute and its value, or the
Namespace
and local name, as well as the value, of
the attribute. Several convenience methods are also provided for
automatic data conversion of the attribute’s value.
public class Attribute { public Attribute(String name, String value); public Attribute(String name, String prefix, String uri, String value); public Attribute(String name, Namespace ns, String value); public String getName( ); public String getQualifiedName( ); ...
Get Java and XML now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.