ASP常用函数之XMLEncode的详细介绍
输出RSS和XML时经常用到,和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
%>
不知道朋友们看完这篇ASP常用函数之XMLEncode的详细介绍文章后,对这方面的了解有没有更进一步呢!爱站技术频道小编每天都会不定时更新文章,需要的话收藏起来以备不时之需吧!