Adding elements

I have a program where I add an element, what happens is for example when you have a details doc

<details>
   <name>
      <first/>
      <last/>
   </name>
   <gender/>
</details>  </pre> <BR>and you want to add another element title.<BR><pre class="ip-ubbcode-code-pre">
Element title = new element("Title");
detailsElement.addContent(title);


The code above will add the element title after the gender element, how do you position your added element so it can be before the gender element or before the name element.

Hi, I assume you are using JDOM. You can get the children of the detailsElement as a java.util.List which is a list of Element objects. So you can add a new Element and set the contents of the updated List using setContent() method. For more information please refer to JDOM and Java documentation.

Hope this helps.

Stuart Fyffe-Collins
Software AG (UK) Ltd.