Skip to content

Instantly share code, notes, and snippets.

@dhamaso
Created September 24, 2015 20:32
Show Gist options
  • Save dhamaso/116a0c672bc41de86b2d to your computer and use it in GitHub Desktop.
Save dhamaso/116a0c672bc41de86b2d to your computer and use it in GitHub Desktop.
Escapar caracteres especiales xml con javascript
function htmlSpecialChars(unsafe) {
return unsafe
.replace(/&/g, "&")
.replace(/</g, "&lt;")
.replace(/>/g, "&gt;")
.replace(/'/g, "&apos;")
.replace(/"/g, "&quot;");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment