[jdom-interest] How would I generate this XML

Yusuf Goolamabbas yusufg at outblaze.com
Thu Jul 13 06:53:02 PDT 2000

Hi, I am relatively newbie Java/XML programmer and believe JDOM will get
me more productive. I was looking at Rusty's slide and compiled one of
his samples. Whilst playing around with it, I found it difficult to
generate the following XML

<?xml version="1.0" encoding="UTF-8"?>
<!-- Yusuf's first comment -->

  Hello JDOM!

Document has a constructor which accepts an Element, The Comment is the
parent of the Element "Greeting", Either, I should be able to set
another XML type as a parent of an Element or Document has a public
constructor which takes no arguments (current no-arg constructor is

Is there a way to generate this. I have attached the example from
Elliote which I was try to modify. My apologies if I missed something
very stupid

Yusuf Goolamabbas
yusufg at outblaze.com
-------------- next part --------------
import org.jdom.*;
import org.jdom.output.XMLOutputter;

public class HelloJDOM {

  public static void main(String[] args) {
    Element root = new Element("GREETING");
    Document doc = new Document(root);      
    root.addChild("Hello JDOM!");
    // At this point the document only exists in memory.
    // We still need to serialize it
    XMLOutputter output = new XMLOutputter();
    try {
      output.output(doc, System.out);       
    catch (Exception e) {



More information about the jdom-interest mailing list