当前位置: 移动技术网 > IT编程>开发语言>Asp > ASP常用函数:XMLEncode

ASP常用函数:XMLEncode

2017年12月12日  | 移动技术网IT编程  | 我要评论

逆差txt,qq闪字下载,it技术论坛

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

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网