Add support for adding sibling elements in a way which preserves order
jakraft opened this issue · 0 comments
jakraft commented
Problem
Currently, the only way to add a sibling element is to append a child element to its parent:
currentElement.up().ele("siblingElement");
This works great if you're building a new XML document from scratch, but it makes it impossible to update an existing XML document in a manner which preserves order. Consider the following document:
<parent>
<child1 />
<child2 />
</parent>
If currentElement
points to <child1 />
, calling .up().ele("siblingElement")
would result in this output:
<parent>
<child1 />
<child2 />
<siblingElement />
</parent>
Proposal
Add two new methods, eleBefore
and eleAfter
, which would add a sibling element before/after the current element.