参考下这个http://www.jdom.org/docs/apidocs/org/jdom2/Document.html
addContent
public Document addContent(Content child)
Appends the child to the end of the content list.
Specified by:
addContent in interface Parent
Parameters:
child - child to append to end of content list
Returns:
the document on which the method was called
Throws:
IllegalAddException - if the given child already has a parent.
addContent
public Document addContent(java.util.Collection<? extends Content> c)
Appends all children in the given collection to the end of the content list. In event of an exception during add the original content will be unchanged and the objects in the supplied collection will be unaltered.
Specified by:
addContent in interface Parent
Parameters:
c - collection to append
Returns:
the document on which the method was called
Throws:
IllegalAddException - if any item in the collection already has a parent or is of an illegal type.
addContent
public Document addContent(int index,
Content child)
Inserts the child into the content list at the given index.
Specified by:
addContent in interface Parent
Parameters:
index - location for adding the collection
child - child to insert
Returns:
the parent on which the method was called
Throws: