fast-xml-parser icon indicating copy to clipboard operation
fast-xml-parser copied to clipboard

Option to remove empty tags completly

Open omasson-perso opened this issue 2 years ago • 6 comments

Is it possible to create an Builder option in order to remove empty tags ?

"suppressEmptyNode" option builds empty tags to self closing tags, but it would be nice to remove it completely on the output.

Thanks !

omasson-perso avatar Mar 13 '22 14:03 omasson-perso

I'm glad you find this repository helpful. I'll try to address your issue ASAP. You can watch the repo for new changes or star it.

github-actions[bot] avatar Mar 13 '22 14:03 github-actions[bot]

We're planning to introduce skipNodes in future version. It might help you.

amitguptagwl avatar Mar 16 '22 01:03 amitguptagwl

Thanks for you quick reply. Do you have a release date ?

Thanks again

omasson-perso avatar Mar 22 '22 08:03 omasson-perso

The decision is still not taken. Check this discussion: https://github.com/NaturalIntelligence/fast-xml-parser/discussions/445

amitguptagwl avatar Mar 23 '22 06:03 amitguptagwl

We're planning to introduce skipNodes in future version. It might help you.

Reading the discussion on skipNodes, it seems that it is intended to be used in XML Parser and you need to specify which node to skip. While options in general seems to work on both Parser and Builder, I don't think that it will help in the original case since they might not know beforehand which node is empty and therefore need to be skipped.

tinusriyanto avatar Aug 18 '23 03:08 tinusriyanto

@tinusriyanto builder is not updated as I started working on v5 of this library where I provided better way to handle it. But i couldn't publish the v5 yet due to some performance issue and my busyness. But to answer your question, from the updateTag method, user will be able to check the value, argument list and other necessary meta data that can help user to decide when to skip a tag in parser or builder.

amitguptagwl avatar Sep 10 '23 00:09 amitguptagwl