ASP常用函数:XMLEncode

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

ASP常用函数:XMLEncode

  2021-03-17 我要评论
想了解ASP常用函数:XMLEncode的相关内容吗,在本文为您仔细讲解的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点: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
%>

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们