[jdom-interest] insert

elephantwalker elephantwalker at home.com
Thu Mar 22 08:54:09 PST 2001

Thanks for all of the posts. Its been awhile since I have used jdom.

-----Original Message-----
From: Uwe_Hale at i2.com [mailto:Uwe_Hale at i2.com]
Sent: Thursday, March 22, 2001 6:55 AM
To: elephantwalker
Cc: jdom-interest at jdom.org; jdom-interest-admin at jdom.org
Subject: Re: [jdom-interest] insert

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]
                    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