[jdom-interest] How do add a child?

Paul Friedman friedmanpaul1 at qwest.net
Mon Nov 12 14:30:42 PST 2001


Try the addContent( Element elt ) method of the Element class.

-----Original Message-----
From: jdom-interest-admin at jdom.org
[mailto:jdom-interest-admin at jdom.org]On Behalf Of
kevin.schmidt at convergys.com
Sent: Monday, November 12, 2001 12:26 PM
To: jdom-interest at jdom.org
Subject: [jdom-interest] How do add a child?



I am using JDOM beta 7 and am trying to add one Element to be a child of
another.
I dont see an addChild method in the API for Element.  Also, it wont let me
call setParent
because it is a protected method.  The only way I can see to do it is like
this:

List childs = elem1.getChildren();
childs.add(elem2);
elem1.setChildren(childs);

This seems very roundabout though.  I must be missing something!  Help!

     -Kevin Schmidt
     Cincinnati, OH



_______________________________________________
To control your jdom-interest membership:
http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhos
t.com





More information about the jdom-interest mailing list