[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.remove(index);
        list.add(index, elem.getCopy(name));
        return list.get(index);
}

Uwe Hale




                                                                                                                                     
                    "elephantwalker"                                                                                                 
                    <elephantwalker at ho        To:     <jdom-interest at jdom.org>                                                       
                    me.com>                   cc:                                                                                    
                    Sent by:                  Subject:     [jdom-interest] insert                                                    
                    jdom-interest-admi                                                                                               
                    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:

<a>
 the beginning
</a>
<c>
 the end
</c>

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

Regards,

Elephantwalker

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








More information about the jdom-interest mailing list