-
Notifications
You must be signed in to change notification settings - Fork 55
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
Attribute ordering #63
Comments
I believe attributes are already ordered? JavaScript has a strange but handy feature where it preserves insertion order of keys on "objects". Since attributes are added to the If you use iterators like Order should also be preserved when going back to XML via Let me know if I'm missing something though! |
Hi @nfarina Thanks for the fast response! Generally you are right of course. But two cases are worth mentioning/considering:
|
Object.entries(someXmlNode.attr).forEach((([attributeName, attrValue]), idx) => {
console.log(`${attributeName} = ${attrValue} is at index ${idx}`);
}); should work for number 2. |
First I'd like to mention that this lib does a great job at parsing XML without loosing und such as white space, comments etc!
It would be great if the order of the attributes could be preserved.
For this, I see two possibilities:
Change
attr
from object to a list of{name: string, value: string}
objects.Add an additional attribute
attrOrder
of that is a ordered list of the attribute names.The text was updated successfully, but these errors were encountered: