When generating XML, special XML characters in XML (&,<,>,") are not encoded properly, leading to invalid XML.
Either pack all values into CDATA or check/replace the special characters - something like:
function escapeXml(unsafe) {
return unsafe.replace(/[<>&'"]/g, function (c) {
switch (c) {
case '<': return '<';
case '>': return '>';
case '&': return '&';
case '\'': return ''';
case '"': return '"';
}
});
}
When generating XML, special XML characters in XML (&,<,>,") are not encoded properly, leading to invalid XML.
Either pack all values into CDATA or check/replace the special characters - something like:
function escapeXml(unsafe) { return unsafe.replace(/[<>&'"]/g, function (c) { switch (c) { case '<': return '<'; case '>': return '>'; case '&': return '&'; case '\'': return '''; case '"': return '"'; } }); }