nashwaan / xml-js

Converter utility between XML text and Javascript object / JSON text.
MIT License
1.28k stars 181 forks source link

xml-js trims off the spaces in the text following each other #214

Open malikiz opened 4 months ago

malikiz commented 4 months ago

xml-js trims off the spaces in the text following each other

<some>some text      </some>

converts to:

{type: "text", "text: "some text "} // where are my spaces??

OR

<some> <some>

converts to:

{type: "element", name: "some"} // And that's it. Where is my text with empty space?
liuyib commented 3 months ago

@malikiz Are you set trim options? Your example works well in my computer (xml-js v1.6.11)

malikiz commented 2 months ago

What about this example? How do I find out how many spaces are present in the text?

console.log(convert.xml2json('<some>     </some>'))
{"elements":[{"type":"element","name":"some"}]}
malikiz commented 2 months ago

I found the captureSpacesBetweenElements property in the sources, but I didn't find it in the documentation. I think this will work for me.