Skip to content

Instantly share code, notes, and snippets.

@atesgoral
Created July 27, 2009 21:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save atesgoral/156752 to your computer and use it in GitHub Desktop.
Save atesgoral/156752 to your computer and use it in GitHub Desktop.
function escapeXml(s) {
return s.replace(/([&<>'"])/g,
function (c) {
return "&" + {
"&": "amp",
"<": "lt",
">": "gt",
"'": "apos",
'"': "quot"
}[c] + ";";
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment