node-xml2js
node-xml2js copied to clipboard
Improve roundtrip for some combinations of parser options
The problem I was trying to solve was to parse some XML data, modify it and encode it back, preserving the order of the XML elements.
The parser have options for that (preserveChildrenOrder
), but the builder is not able to follow the new structure.
The PR addresses the object structure, addresses the cases where the explicitChildren
or preserveChildrenOrder
options are set. Two new test cases have been added for them.
This is done not relying in additional builder options. This way the parser can accept objects produced by parsers with different options.
I've also refactored slightly the builder loop making these metadata keys ($
, $$
, _
) addressed before going into the key loop (allowing to take the decision of not looking into the remaining redundant keys)
Coverage decreased (-0.2%) to 97.479% when pulling f16cad0af33119efdf553d838777337575017ede on j-santander:master into 049242dbefc2d69e8e8ceac566b9e862a58c9ff1 on Leonidas-from-XIV:master.
Coverage decreased (-0.2%) to 97.479% when pulling f16cad0af33119efdf553d838777337575017ede on j-santander:master into 049242dbefc2d69e8e8ceac566b9e862a58c9ff1 on Leonidas-from-XIV:master.
Coverage increased (+0.7%) to 98.333% when pulling b0c51f810e2df13e40aeab966e8388a09c9f4adb on j-santander:master into 049242dbefc2d69e8e8ceac566b9e862a58c9ff1 on Leonidas-from-XIV:master.
I'll try to add some more test later....
This works great and should be merged !
I know this PR is super old but I would still love to see it merged!