Hi,
I am trying to move elements in a list with, by placing the element to move after an element that was found to be the previous element:
list children = parentElem.elements(); int indexPos = children.indexOf(previousElem);
if (index == -1) { children.add(moveElem); } else { children.add(index + 1, moveElem); }
This works if I have more than one element. If I have only one element in the children list, then the moveElem is placed at the first position in the list.
XML for this problem would look like:
<parent id="abc"> <child id="def"/> </parent>
so the child element is set to be the previousElem. The result of the above code is:
<parent id="abc"> <child id="newElem"/> <child id="def"/> </parent>
thanks for any help, -Rob
------------------------------------------------------- SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33 Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift. http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285 _______________________________________________ dom4j-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/dom4j-user