Leonidas-from-XIV / node-xml2js

XML to JavaScript object converter.
MIT License
4.88k stars 602 forks source link

Added optional comment handling #504

Open visorgames opened 5 years ago

visorgames commented 5 years ago

XML-Comments can now be parsed or build. The comments can be accessed via the commentskey (default: $comments) under their parent node. To activate this feature, the option parseComments has to be set to true.

To support multiple comments contained in the same tag, the comments are pushed to an array like any other node. Comments are only parsed if they are at least inside the root node. The position of comments in the xml is only reliably preserved if they are not placed in between child tags with the same name (eg.: <test>...</test><!-- comment --><test>...</test>) or are split by an other child tag (eg.: <!-- comment1 --><test/><!-- comment2 -->). Otherwise the original xml-structure can be rearranged, as nodes with the same tag-name get parsed into an array.

This feature was already requested in the past: #44, #475

coveralls commented 5 years ago

Coverage Status

Coverage increased (+0.09%) to 97.727% when pulling 0bdbccec642da390662d2aa998c0cb5e91074100 on visorgames:master into 0f0a2980b3db5366b3d50e4d0da422cb7af100c9 on Leonidas-from-XIV:master.

coveralls commented 5 years ago

Coverage Status

Coverage increased (+0.09%) to 97.727% when pulling 0bdbccec642da390662d2aa998c0cb5e91074100 on visorgames:master into 0f0a2980b3db5366b3d50e4d0da422cb7af100c9 on Leonidas-from-XIV:master.

ainthek commented 4 years ago

+1 when will this be available please ?

Leonidas-from-XIV commented 4 years ago

There is no plan for it at the moment.

mastakillahBlitzar commented 3 years ago

How can we contribute to pull this through ? very helpful

TaroXin commented 3 years ago

@mask

How can we contribute to pull this through ? very helpful

I found a library that is better adapted and also supports comments parsing, https://github.com/oozcitak/xmlbuilder2

I have seen the information you left from many libraries, I believe you are also very anxious