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.56k stars 306 forks source link

questions about: innerHtml self closing br tag #482

Closed tidys closed 2 years ago

tidys commented 2 years ago

Discussed in https://github.com/NaturalIntelligence/fast-xml-parser/discussions/481

version:4.0.8

The problem with innerHtml br

My xml data comes from innerHTML, like this: <font size="20">1<br>2<br>3</font>br is not self closing image When I try to parse this xml,this will cause the text to be parsed into the br tag image The above array of data will be built and the result will be <font size="20">1<br>2</br><br>3</br></font> This is not the result I was expecting, I looked at the source code, it seems that there is no good way Here's how I've solved it so far, the xml data is first replaced globally as shown below replace(/<br>/g, '<br/>');

github-actions[bot] commented 2 years ago

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.

amitguptagwl commented 2 years ago

Sorry. Can you please describe in English?

tidys commented 2 years ago

I've updated it and I feel like I can consider adding a self closing tag logic

tidys commented 2 years ago

in version:4.09, i found stopNodes can fix my problem https://github.com/NaturalIntelligence/fast-xml-parser/blob/HEAD/docs/v4/2.XMLparseOptions.md#stopnodes