加入收藏 | 设为首页 | 会员中心 | 我要投稿 汽车网 (https://www.0577qiche.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > Asp教程 > 正文

ASP寻常函数 XMLEncode

发布时间:2023-08-17 12:53:49 所属栏目:Asp教程 来源:
导读:输出RSS和XML时经常用到,和HTMLEncode还不完全一样<%Function XMLEncode(byVal sText) sText = Replace(sText, "&" , "&") sText = Replace(sText, "<" , "<") sText = Replace(sText, ">" , ">"

输出RSS和XML时经常用到,和HTMLEncode还不完全一样

<%

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

%>

(编辑:汽车网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章