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

Same options from Parser to Builder produce a different output

Open Alex-Ferreli opened this issue 5 years ago • 7 comments

Hi! I'm trying to parse, manipulate, and build an XML file.

I found the option to create an array of child (to maintain the order in built XML file), so i use it. But when i generate back the XML seems like tat the builder didn't see the options, so he generate a totally different output (put children as XML node, but should loop over them and generate the right tags).

It's possible that Builder didn't accept the same options as Parser?

Thanks in advance!

Alex-Ferreli avatar Apr 11 '19 16:04 Alex-Ferreli

Yes, I don't think the code is well suited for roundtrips. The builder should just be removed :-(

Leonidas-from-XIV avatar Apr 11 '19 17:04 Leonidas-from-XIV

Then there is now way to re-generate a correct XML? :(

Do you know some great alternative of your plugin? This is so good because is ridiculously easy to use, to read XML it's fantastic. The problem is only for the generation of XML with ordered childrens :(

Alex-Ferreli avatar Apr 11 '19 17:04 Alex-Ferreli

Well, you can still use xml2js for parsing and construct XML in a different way.

xml2js is due for a proper rewrite but since I don't use it personally I have little time to spend on it.

Leonidas-from-XIV avatar Apr 11 '19 17:04 Leonidas-from-XIV

Yes, i'm still using it to parsing.

I wrote a function that loop over an element (attributes and childrens) and generate full XML.

Alex-Ferreli avatar Apr 12 '19 13:04 Alex-Ferreli

@Alex-Ferreli Would you mind sharing it ?

brospars avatar Aug 04 '20 14:08 brospars

Nevermind #461 works great

brospars avatar Aug 06 '20 10:08 brospars

Can we get #461 merged?

chpio avatar Apr 12 '21 14:04 chpio