网络编程
位置:首页>> 网络编程>> Asp编程>> asp函数转换xml中的实体字符[转义符]

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

作者:佚名 来源:aspxuexi.com 发布时间:2008-10-16 17:07:00 

标签:




<%
Function XMLEncode(byVal sText)
sText = Replace(sText, "&" , "&amp;")
sText = Replace(sText, "<" , "&lt;")
sText = Replace(sText, ">" , "&gt;")
sText = Replace(sText, "'" , "&apos;")
sText = Replace(sText, """", "&quot;")
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
%>


0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com