Choose where you’d like to start

XML Encode

Description

The xmlEncode function is used to transform all special XML characters in the input text into XML entities. This operation has several purposes, for example, to put XML inside of XML, to ensure the text will be properly rendered in the browser, etc. To perform reverse operation, i.e., decode XML entities to XML text, use xmlDecode function.

Note:
  • The size of the supplied input text and the returned output text can individually be up to 300KB.
  • This function supports all XML tags until the latest version.

Syntax

<response> = <data>.xmlEncode();
(or)
<response> = xmlEncode(<data>);

where:

ParamsData typeDescription

<response>

TEXT

Specifies the response that represents the encoded XML data

<data>

TEXT

Specifies the XML text that needs to be encoded.

Example 1: Encode a XML text to XML entities

The following script encodes the input XML text such that all the special characters will be transformed into their equivalent HTML entities.

response = xmlEncode("Your order is ready.<br />You can track your order's status using our app. Thank you.");

where:

response
The TEXT response that represents the base 64 encoded data. This example returns - Your order is ready.&lt;br /&gt;You can track your order&apos;s status using our app. Thank you.
"Your order is ready.<br />Thank you."
The TEXT that represents the XML text that needs to be encoded

Related Links

Get Started Now

Execute