michaelkourlas / node-js2xmlparser

Popular Node.js module for parsing JavaScript objects into XML
https://www.npmjs.org/package/js2xmlparser
Apache License 2.0
221 stars 52 forks source link

How do I add a non breaking space #68

Closed jtbairdsr closed 5 years ago

jtbairdsr commented 6 years ago

if I try to add a non breaking space literal   to the value of an element, the ampersand gets encoded to & which breaks the non breaking space (perhaps a bit ironic...) is there a way for me to prevent the encoding of the ampersand or do I just need to rethink my usage of non breaking spaces?

gauravumrani commented 6 years ago

have you find solution?

jtbairdsr commented 6 years ago

I have not... I am currently rethinking my usage of non breaking spaces.

gauravumrani commented 6 years ago

I search alot on Google..but couldn't found a solution for that..finally switched to https://www.npmjs.com/package/jsontoxml This package works perfectly

michaelkourlas commented 5 years ago

js2xmlparser isn't expecting raw XML in strings -- it assumes you want it preserved as text.

If you want a non-breaking space, just use a Unicode literal instead: "\u00A0".