This week's book giveaway is in the Reactive Progamming forum. We're giving away four copies of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams and have Adam Davis on-line! See this thread for details.
I running into trouble with the DOM4J api. I want to substitute an element within an existing XML document for another element (with children). So far so good. I made copies of the dom4j trees that I need, made sure to detach, also took the effort to take the root element instead of the document node. But I run into trouble when I want to insert. Apparently I can only insert as the last child node of the element I'm adding to. This is not what I need. I need to be sure the inserted element will be at the right place. Does anyone know how to do this, other than removing and adding all child nodes to the parent?
R. V. Ijzer
posted 10 years ago
OK, So it seems there is a content method for an element that returns a list of the childeren of the element. This list is the same as used by the element. So any changes to this list are changes to the element. Adding the new element to the right place in the list solved my problem.