Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for adding sibling elements in a way which preserves order #111

Open
jakraft opened this issue Oct 14, 2021 · 0 comments
Open

Comments

@jakraft
Copy link

jakraft commented Oct 14, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant