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

Trying to do an exact rebuild

Open aletorrado opened this issue 10 years ago • 5 comments

Hi, I'm trying to modify a XML file and rebuilding it, avoiding any mismatch. So I'm parsing it using:

{
  explicitRoot: false,
  preserveChildrenOrder: true,
  explicitChildren: true
}

This way, I'm getting the exact representation of the original XML, but I cannot rebuild it this way with the default builder. How can I achieve this?

Thanks!

aletorrado avatar May 11 '16 19:05 aletorrado

This would be interesting for me as well. Do you plan to release an update that supports building of an xml from an object that was parsed using these settings soon?

flodev avatar Jun 27 '16 08:06 flodev

No plans at the moment. I am doubting that adding XML output was a good idea to start with.

Leonidas-from-XIV avatar Jun 27 '16 08:06 Leonidas-from-XIV

Thats a pity. I need this feature. I'm trying to implement it and if I succeed I will contribute it.

flodev avatar Jun 29 '16 14:06 flodev

#307

The pull req is created. I copied all builder unit tests to ensure having the expected result when building an xml.

flodev avatar Jul 04 '16 06:07 flodev

@Leonidas-from-XIV currently you are trying to create an exact JSON object with preserved order but you have never checked how the XML will look that is built from an exact object. So how do you make sure that your object built with explicitChildren and preserveOrder contains everything necessary? My tests are covering this and the pull request also contains fixes for building this object.

Unfortunately your recent commits are conflicting with my changes. I don't have time to fix the merge conflicts because its implemented once for a project of a client. If you are willing to merge the pull request I would resolve the conflicts once. Otherwise I will abandon my fork.

flodev avatar Jul 06 '16 13:07 flodev