SV: [jdom-interest] create xml tree
pernorrman at telia.com
Mon Feb 2 04:57:28 PST 2004
this one was hard to understand ...
> I am trying to find out if there is a way of adding children
> in a way that the parent-child relation will be kept.
When you add one element (child) to another element (parent),
you create a parent-child relationship. Which parent-child
relationship do you want to be preserved?
> I have a method to create the relation inbetween parent and
> child. I then want to make a recursive add of
> children to each parent. I have about 8 levels of
> parent-child relations. Doing
> seems only to add the first level. How can I make it recursive?
You cannot make it recursive! Where are the grand children, and the
grand-grand children, etc?
> Do I have to keep track of the element that I start to add
> children to and when all my addContent have been done I add
> the first element to the root and last create a Document?
Not knowing what your'e trying to do, but here are two hints:
1) if youre tree is static, one alternative is to use a bottom-up
approach (although I do not really recommend the coding style):
Element e =
(At least the tree structure is obvious :-))
2) if your tree is dynamic, you must have some representation of it
you go off and construct the JDOM tree. This representation must then be
and the JDOM tree built up along the way.
More information about the jdom-interest