// Collection of code snippets by Arne VajhÃ¸j 
// (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) 
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.output.Format;
import org.jdom.output.XMLOutputter;

public class CreateJDOM {
    public static void main(String[] args) {
        // lav nyt DOM træ
        Document doc = new Document();
        // tilføj elementer til DOM træ
        Element one1 = new Element("one");
        one1.setText("A");
        Element one2 = new Element("one");
        one2.setText("BB");
        Element one3 = new Element("one");
        one3.setText("CCC");
        Element all = new Element("all");
        all.addContent(one1);
        all.addContent(one2);
        all.addContent(one3);
        doc.setRootElement(all);
        // udskriv DOM træ
        XMLOutputter fmt = new XMLOutputter(Format.getPrettyFormat());
        System.out.println(fmt.outputString(doc));
    }
}
