I search the web alot and didn't find js function that replace xml Special Character with their escape sequence?
Is there something like this?
I know about the following:
Special Character Escape Sequence Purpose
& & Ampersand sign
' ' Single quote
" " Double quote
> > Greater than
< < Less than
is there more? what about writing hexadecimal value like 0×00,
Is this also a problem?
Special characters (such as <, >, &, ", and ' ) can be replaced in XML documents with their html entities using the DocumentKeywordReplace service. However, since html entities used within BPML are converted to the appropriate character, the string mode of DocumentKeywordReplace will not work in this instance.
To use a special character as a regular one, prepend it with a backslash: \. . That's also called “escaping a character”.
I have used this:
function htmlSpecialChars(unsafe) {
return unsafe
.replace(/&/g, "&")
.replace(/</g, "<")
.replace(/>/g, ">")
.replace(/"/g, """)
.replace(/'/g, "'");
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With