encode_xml

NAME

encode_xml(): Encode a given text for XML.

TYPE

Function

DESCRIPTION

Return the given text valid for XML, with special characters properly encoded.

SYNOPSIS

encode_xml(txt TEXT CHARSET utf8)
  RETURNS TEXT CHARSET utf8 

Input:

  • txt: an arbitrary text, to be encoded

EXAMPLES

Encode a normal text (no change expetced):

mysql> SELECT encode_xml('The quick brown fox') AS encoded;
+---------------------+
| encoded             |
+---------------------+
| The quick brown fox |
+---------------------+

Encode a text with special characters:

mysql> SELECT encode_xml('3 > "2" & 4 < 5') AS encoded;
+-------------------------------------+
| encoded                             |
+-------------------------------------+
| 3 &gt; &quot;2&quot; &amp; 4 &lt; 5 |
+-------------------------------------+

ENVIRONMENT

MySQL 5.1 or newer

SEE ALSO

decode_xml()

AUTHOR

Shlomi Noach
 
common_schema documentation