xml-js icon indicating copy to clipboard operation
xml-js copied to clipboard

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

Open malikiz opened this issue 1 year ago • 3 comments

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?

malikiz avatar May 10 '24 09:05 malikiz

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

liuyib avatar Jun 04 '24 08:06 liuyib

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 avatar Jun 25 '24 16:06 malikiz

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

malikiz avatar Jun 25 '24 17:06 malikiz