NaturalIntelligence / fast-xml-parser

Validate XML, Parse XML and Build XML rapidly without C/C++ based libraries and no callback.
https://naturalintelligence.github.io/fast-xml-parser/
MIT License
2.43k stars 297 forks source link

Parsing of Empty Tags #631

Open khkiley opened 6 months ago

khkiley commented 6 months ago

Description

I am looking for a way to provide a default value for empty tags, to override the default of empty string. Similar to issue #630

ETA: #619 may also be related.

Empty tags are not processed through the tagValueProcessor (which makes sense as there is no value to process) but then the value is always an empty string, and there is no way I am aware of, to transpose the value.

The use case is for a data set that sends flags down as an empty tag. ie.

<thisIsAFlag /> 

// would be parsed as 
{ thisIsAFlag: true }

// instead of 
{ thisIsAFlag:'' }

Bookmark this repository for further updates. Visit SoloThought to know about recent features.

github-actions[bot] commented 6 months ago

We're glad you find this project helpful. We'll try to address this issue ASAP. You can vist https://solothought.com to know recent features. Don't forget to star this repo.

amitguptagwl commented 6 months ago

There are multiple possibilities. Hence, I've come up with a common solution in v5. Development of parser was completed few months back. But I'm not getting time to finish UTs and complete the changes in Builder. So please wait for the next release

khkiley commented 6 months ago

Thank you, Amit, for your quick reply and all your hard work supporting this package.

I will keep an eye out for V5

Kurt

amitguptagwl commented 3 months ago

I had updated the documents for v5. Please check it with latest version.