[jdom-interest] insert

Uwe_Hale at i2.com Uwe_Hale at i2.com
Thu Mar 22 06:55:09 PST 2001

One way is to get the list of elements and add it at a particular index.
Here is some code I'm using to get around the lack of a setname method.

    public static Object changeElementName(Object obj, String name)
        Element elem = (Element)obj;
        Element parentElem = elem.getParent();

        List list = parentElem.getChildren();
        int index = list.indexOf(elem);
        list.add(index, elem.getCopy(name));
        return list.get(index);

Uwe Hale

                    <elephantwalker at ho        To:     <jdom-interest at jdom.org>                                                       
                    me.com>                   cc:                                                                                    
                    Sent by:                  Subject:     [jdom-interest] insert                                                    
                    n at jdom.org                                                                                                       
                    03/22/01 04:34 AM                                                                                                

don't know this for sure, but is there a way to "insert" and element in a
particular order?

if I have elements:

 the beginning
 the end

And I would like to insert <b>the middle</b> in between <a> and <c>, how is
it done?



To control your jdom-interest membership:

More information about the jdom-interest mailing list