ASP常用函數(shù):XMLEncode
輸出RSS和XML時經(jīng)常用到,和HTMLEncode還不完全一樣
原理:
| Character | Converted To |
| " | " |
| ' | ' |
| & | & |
| < | < |
| > | > |
代碼
<%
Function XMLEncode(byVal sText)
sText = Replace(sText, "&" , "&")
sText = Replace(sText, "<" , "<")
sText = Replace(sText, ">" , ">")
sText = Replace(sText, "'" , "'")
sText = Replace(sText, """", """)
XMLEncode = sText
End Function
%>
還有個:
<%
Public Function XmlEncode(ByVal strText As String) As String
Dim aryChars() As Variant
aryChars = Array(38, 60, 62, 34, 61, 39)
Dim i As Integer
For i = 0 To UBound(aryChars)
strText = Replace(strText, Chr(aryChars(i)), "&#" & aryChars(i) & ";")
Next
XmlEncode = strText
End Function
%>
相關(guān)文章
javascript asp教程第三課 new String() 構(gòu)造器
javascript asp教程第三課 new String() 構(gòu)造器...2007-03-03
asp模板引擎終結(jié)者(WEB開發(fā)之ASP模式)
[紅色]asp模板引擎終結(jié)者(WEB開發(fā)之ASP模式)...2006-06-06
ASP trim,ltrim,rtrim 去前后空格 函數(shù)
Trim 函數(shù)可返回不帶前導(dǎo)與后續(xù)空格 (Trim) 的字符串.2010-05-05
ASP中Request對象獲取客戶端數(shù)據(jù)的順序(容易忽略)
ASP中Request對象獲取客戶端數(shù)據(jù)的順序(容易忽略)...2006-08-08

