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)文章
asp,VBscript語法錯誤,史上最全最詳細(xì)最精確
asp,VBscript語法錯誤,史上最全最詳細(xì)最精確...2007-03-03javascript asp教程第八課--request對象
javascript asp教程第八課--request對象...2007-03-03ASP編程入門進(jìn)階(十八):FSO組件之文件操作(上)
ASP編程入門進(jìn)階(十八):FSO組件之文件操作(上)...2007-01-01