[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.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@yourhos
t.com








More information about the jdom-interest mailing list