APGen Documentation Previous Topic: Util.URLEncode() Next Topic: ApgLogFlags Enum Parent Topic: Util Object    Util Object
Util.XMLEncode()
See Also:

The Util.XMLEncode() method applies XML encoding rules to a string.

Syntax

VBScript:

strEncoded = Util.XMLEncode( str )

JScript:

strEncoded = Util.XMLEncode( str );

Object

Util The Util object.

Parameters

str The string to be encoded.

Return Value

strEncoded The XML encoded string.

Notes

XML encoding is simpler than HTML encodingUtil.XMLEncode() adheres to the XML 1.0 standard.

The following characters are converted:

Character Converted To
" "
' '
& &
< &lt;
> &gt;

Example

This example encodes a string for inclusion in an XML document:

<%# @LANGUAGE="VBScript" #%>
<%#

Output.Filename = "quotes.xml"

Dim sQuote, sAuthor
sQuote = "My mother said to me, ""If you become a soldier " & _
     "you'll be a general; if you become a monk you'll end " & _
     "up as the pope."" Instead, I became a painter and wound " & _
     "up as Picasso."
sAuthor = "Pablo Picasso"

#%><?xml version="1.0" encoding="UTF-8"?>
<quotes>
     <quote author="
<%# =Util.XMLEncode(sAuthor) #%>"
       >
<%# =Util.XMLEncode(sQuote) #%></quote>
</quotes>

Applies To

Util Object