asp函数转换xml中的实体字符[转义符]

网络整理 - 09-06

以下为引用的内容:

<%
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(strText)
Dim aryChars
aryChars = Array(38, 60, 62, 34, 61, 39)
Dim i
For i = 0 To UBound(aryChars)
strText = Replace(strText, Chr(aryChars(i)), "&#" & aryChars(i) & ";")
Next
XmlEncode = strText
End Function
%>