I have the following JS code (with some jQuery) that prints errors from an array to bootstrap container:
var errors = [{
"Message": "The source document is not valid. Please see the 'Schema
Validation Issues' section above at column &1, line &2"
}, {
"Message": "The metadata element \"Resource Title\" is missing, empty or
incomplete but it is required. Hint: \"A non-empty title is required for
Spatial Data Sets and Spatial Data Set Series but none could be found.\"",
}, {
"Message": "In content of element <CI_Citation>: The content model does not
allow element <Q{.../gmd}date> to appear as the first child. It must be preceded by <Q{.../gmd}title>. at column 31, line 73",
}];
$.each(errors, function(key, val) {
var output = document.createElement("div");
output.setAttribute("class", "alert alert-danger");
output.innerHTML = '<strong>Error: </strong>'+val.Message;
output.getElementById('container').appendChild(output);
});
Since some of my messages contain HTML/XML tags (see message 3.), they get printed as HTML instead of pure strings. How can I escape this? I need these messages printed as strings.