XMLENCOD: XML-Encoding Characters

How to:

The XMLENCOD function encodes the following five standard characters when they are encountered in a string:

Character Name

Character

Encoded Representation

ampersand

&

&

greater than symbol

>

>

less than symbol

<

&lt;

double quotation mark

"

&quot;

single quotation mark (apostrophe)

'

&apos;



x
Syntax: How to XML-Encode Characters
XMLENCOD(inlength, source_string, option, outlength,  output)

where:

inlength

Integer

Is the length of the field containing the source character string or a field that contains the length.

source_string

Alphanumeric

Is the name of the field containing the source character string or a string enclosed in single quotation marks (').

option

Integer

Is a code that specifies whether to process a string that already contains XML-encoded characters. Valid values are:

  • 0, the default, which cancels processing of a string that already contains at least one XML-encoded character.
  • 1, which processes a string that contains XML-encoded characters.
outlength

Integer

Is the length of the output character string or a field that contains the length.

Note: The output length, in the worst case, could be six times the length of the input.

output

Integer



Example: XML-Encoding Characters

XMLENCOD XML-encodes characters and stores the output in a string with format A30:

XMLENCOD(30, INSTRING, 30, 1, 'A30')

For &, the result is &amp;.

For >, the result is &gt;.


iWay Software