node-xml2js icon indicating copy to clipboard operation
node-xml2js copied to clipboard

Improve roundtrip for some combinations of parser options

Open j-santander opened this issue 6 years ago • 6 comments

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)

j-santander avatar Jun 07 '18 05:06 j-santander

Coverage Status

Coverage decreased (-0.2%) to 97.479% when pulling f16cad0af33119efdf553d838777337575017ede on j-santander:master into 049242dbefc2d69e8e8ceac566b9e862a58c9ff1 on Leonidas-from-XIV:master.

coveralls avatar Jun 07 '18 05:06 coveralls

Coverage Status

Coverage decreased (-0.2%) to 97.479% when pulling f16cad0af33119efdf553d838777337575017ede on j-santander:master into 049242dbefc2d69e8e8ceac566b9e862a58c9ff1 on Leonidas-from-XIV:master.

coveralls avatar Jun 07 '18 05:06 coveralls

Coverage Status

Coverage increased (+0.7%) to 98.333% when pulling b0c51f810e2df13e40aeab966e8388a09c9f4adb on j-santander:master into 049242dbefc2d69e8e8ceac566b9e862a58c9ff1 on Leonidas-from-XIV:master.

coveralls avatar Jun 07 '18 05:06 coveralls

I'll try to add some more test later....

j-santander avatar Jun 07 '18 05:06 j-santander

This works great and should be merged !

brospars avatar Aug 06 '20 10:08 brospars

I know this PR is super old but I would still love to see it merged!

samatcolumn avatar Aug 22 '22 08:08 samatcolumn