代码<%FunctionXMLEncode(byValsText)sText=Replace(sText, 金钱帮资源网更新日期:2024/9/22" />
网络编程 
首页 > 网络编程 > 浏览文章

ASP常用函数:XMLEncode

(编辑:jimmy 日期: 2024/9/22 浏览:3 次 )

输出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
%>

上一篇:查看所有的Server Variables的环境变量
下一篇:ASP常用函数:CLngIP()
一句话新闻
Windows上运行安卓你用过了吗
在去年的5月23日,借助Intel Bridge Technology以及Intel Celadon两项技术的驱动,Intel为PC用户带来了Android On Windows(AOW)平台,并携手国内软件公司腾讯共同推出了腾讯应用宝电脑版,将Windows与安卓两大生态进行了融合,PC的使用体验随即被带入到了一个全新的阶段。
友情链接:杰晶网络 DDR爱好者之家 南强小屋 黑松山资源网 白云城资源网 SiteMap