escapeXML()function

escapeXML(value: string): string
ParamType
valuestring
The raw string value. required
Return
string
The escaped XML-safe string.

Escape a string for safe inclusion in XML text content or attribute values.

  • Replaces &, <, >, ", and ' with their XML entity equivalents.

Examples

escapeXML(`Tom & "Jerry"`) // "Tom &amp; &quot;Jerry&quot;"