|
Util Object |
|
See Also: |
The Util.XMLEncode() method applies XML encoding rules to a string.
VBScript:
JScript:
| Util | The Util object. |
| str | The string to be encoded. |
| strEncoded | The XML encoded string. |
XML encoding is simpler than HTML encoding. Util.XMLEncode() adheres to the XML 1.0 standard.
The following characters are converted:
| Character | Converted To |
| " | " |
| ' | ' |
| & | & |
| < | < |
| > | > |
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>