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.
Problem
Currently, the only way to add a sibling element is to append a child element to its parent:
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:
If
currentElementpoints to<child1 />, calling.up().ele("siblingElement")would result in this output:Proposal
Add two new methods,
eleBeforeandeleAfter, which would add a sibling element before/after the current element.