November 2002
Intermediate to advanced
1120 pages
21h 2m
English
Let's begin with a simple JDOM program that creates the following XML document:
<?xml version="1.0"?> <GREETING>Hello JDOM!</GREETING>
As all documents should have root elements, we'll need to create the root GREETING element first, then use that element to create the document:
Element root = new Element("GREETING");
root.setText("Hello JDOM!");
Document doc = new Document(root);
Note
Initially the Element object is not associated with any Document. It is freestanding. This contrasts with DOM, which requires that all nodes are always part of some document. JDOM allows nodes to stand on their own if that's useful. However, JDOM does not allow a node to be part of two documents at once. Before an Element can ...
Read now
Unlock full access