Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
malikiz opened this issue May 10, 2024 · 3 comments
Open

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

malikiz opened this issue May 10, 2024 · 3 comments

Comments

@malikiz
Copy link

malikiz commented May 10, 2024

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
Copy link

liuyib commented Jun 4, 2024

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

@malikiz
Copy link
Author

malikiz commented Jun 25, 2024

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
Copy link
Author

malikiz commented Jun 25, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants