无为清净楼资源网 Design By www.qnjia.com

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

原理:
Character Converted To " &quot; ' &apos; & &amp; < &lt; > &gt;

代码
<%
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(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

无为清净楼资源网 Design By www.qnjia.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
无为清净楼资源网 Design By www.qnjia.com

更新日志

2024年09月20日