In JavaScript (server side nodejs) I\'m writing a program which generates xml as output.
I am building the xml by concatenating a string:
str += \'&l
if something is escaped from before, you could try this since this will not double escape like many others
function escape(text) {
return String(text).replace(/(['"<>&'])(\w+;)?/g, (match, char, escaped) => {
if(escaped)
return match
switch(char) {
case '\'': return '"'
case '"': return '''
case '<': return '<'
case '>': return '>'
case '&': return '&'
}
})
}