That did it - thanks
-----Original Message----- From: Maarten Coene [mailto:[EMAIL PROTECTED] Sent: Thursday, December 09, 2004 4:33 AM To: Ben Munat Cc: [EMAIL PROTECTED]; David Thielen Subject: Re: [dom4j-user] insert an element Hi Ben, David, as far as I know this is indeed the only way to add child Nodes at a given position: int position = [...]; // the position of the new element Element newElement = [...]; // the new element Element parent = [...]; List children = parent.elements(); children.add(position, newElement); regards, Maarten Ben Munat wrote: > I ran into that at one point... looked and looked but never found > anything in the API like a "insertBefore" or "insertAfter"... I think > that would be a nice addition, I mean even the w3c DOM has that. > > On the other hand there's always the good ol' fashioned way: iterating > through the children until you get to element you want to insert > before or after. That's probably how it'd be done in an "insert" > method anyway. > > b > > PS: other list folks, I'd love to hear I'm wrong about this. > > > > David Thielen wrote: > >> Hi; >> >> >> >> addElement() adds an element at the end of the elements held by the >> parent. How can I insert a new element so it's not placed at the end >> of the child elements? >> >> >> >> Thanks - dave >> > > > ------------------------------------------------------- > SF email is sponsored by - The IT Product Guide > Read honest & candid reviews on hundreds of IT Products from real users. > Discover which products truly live up to the hype. Start reading now. > http://productguide.itmanagersjournal.com/ > _______________________________________________ > dom4j-user mailing list > [EMAIL PROTECTED] > https://lists.sourceforge.net/lists/listinfo/dom4j-user > ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://productguide.itmanagersjournal.com/ _______________________________________________ dom4j-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/dom4j-user