I need to prepend HTML to existed XOM element. HTML represented as a String.
Here are my actions
- Parse String into XOM Document
- Remove root element(X) from Document
- Prepend X to desired target element (Y)
I get an exception
nu.xom.WellformednessException: Cannot remove the root element
at nu.xom.Document.removeChild(Unknown Source)
at nu.xom.Node.detach(Unknown Source)
X element HTML
<div>
Some test text
</div>
Current XOM implementation does not allow to remove root node.
To achieve desired goal it is need to add fake root and then detach required node.
In a context of mentioned step set:
Replace step 2 with next
document.setRootElement(new Element("div"))element.detach()