JDOM 1.0 (Beta 7)

JDOM 1.0 (beta 7), detailed in Chapter 7 and 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 instantiation of objects directly 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

This package contains the core classes for JDOM 1.0[31]. These consist of XML objects modeled in Java and a set of Exceptions that can be thrown when errors occur.[32]

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 value, Namespace ns); public Element getParent( ); public String getName( ); public Namespace getNamespace( ); public ...

Get Java and XML, Second Edition 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.