I have a org.dom4j.Document
instance that is a DefaultDocument implementation to be specific. I would like to insert a new node just before an other one. I do not really understand the dom4j api, I am confused of the differences between Element
and DOMElement
and stuff.
org.dom4j.dom.DOMElement.insertBefore
is not working for me because the Node I have is not a DOMElement. DOMNodeHelper.insertBefore
is nor good because I have org.dom4j.Node
instances and not org.w3c.dom.Node
instances. OMG.
Could you give me a little code snippet that does this job for me?
This is what I have now:
// puts lr's to the very end in the xml, but I'd like to put them before 'e'
for(Element lr : loopResult) {
e.getParent().add(lr);
}
e
mentioned in the snippet is also an Element, nothing special about it nor its parent. Thee.getParent()
is just a general Element, more specifically a node in my xml tree. – Fortyfour