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
%>
相关推荐
-
ASP常用函数:XMLEncode
输出RSS和XML时经常用到,和HTMLEncode还不完全一样 原理: Character Converted To " " ' ' & & < < > > 代码<%Function XMLEncode(byVal sText) sText = Replace(sText, "&" , "&") sText = Replace(sText, "
-
ASP常用函数收藏乱七八糟未整理版
<% '******************************************************************* '取得IP地址 '******************************************************************* Function Userip() Dim GetClientIP '如果客户端用了代理服务器,则应该用ServerVariables("HTTP_X_FORWARDED_FOR&
-
asp 常用函数用法
Array() FUNCTION: 返回一个数组 SYNTAX: Array(list) ARGUMENTS: 字符,数字均可 EXAMPLE: <% Dim myArray() For i = 1 to 7 Redim Preserve myArray(i) myArray(i) = WeekdayName(i) Next %> RESULT: 建立了一个包含7个元素的数组myArray myArray("Sunday",&
-
ASP常用函数:Trace()
复制代码 代码如下: <% '//---- 输入字符串并结束当前页面(调试用),函数可以也命名为Debug ----// Function Trace(s) On Error Resume Next Response.Write(s & vbCrLf) Response.End() End Function %> 下面的是个修改升级版,还在测试中... 复制代码 代码如下: <% '//---- 输入字符串并结束当前页面(调试用) ---
-
ASP常用函数:Delay()
代码很短,但是很经典,单位是秒,就是未测试过服务器资源消耗怎么样: <% Function Delay(s) Dim t = Now() While DateDiff("s", t, Now) < s Wend End Function %> 转载自:http://jorkin.reallydo.com/article.asp?id=224
-
ASP常用函数:CStrIP()
作用:把长整型数字转为IP地址 <% Function CStrIP(ByVal anNewIP) Dim lsResults Dim lnTemp Dim lnIndex For lnIndex = 3 To 0 Step -1 lnTemp = Int(anNewIP / (256 ^ lnIndex)) lsResults = lsResults & lnTemp & "." a
-
ASP常用函数:ReplaceHTML
<% '去掉HTML标记 Public Function ReplaceHTML(Textstr) Dim Str, re Str = Textstr Set re = New RegExp re.IgnoreCase = True re.Global = True re.Pattern = "<(.[^>]*)>" Str = re.Replace(Str, "") Set R
-
ASP常用函数:ArrayToxml
<% Public Function ArrayToxml(DataArray, Recordset, row, xmlroot) Dim i, node, rs, j If xmlroot = "" Then xmlroot = "xml" Set ArrayToxml = Server.CreateObject("msxml2.FreeThreadedDOMDocument"& MsxmlVersion)
-
ASP常用函数:HTMLDecode
<% Function HTMLDecode(sText) Dim I sText = Replace(sText, "&" , Chr(38)) sText = Replace(sText, """", Chr(34)) sText = Replace(sText, "<" , Chr(60)) sText = Replace(sText, ">&q
-
[转]ASP常用函数:TimeZone
功能:获取服务器所在时区 复制代码 代码如下: <% Function TimeZone() Set oShell = CreateObject("WScript.Shell") atb = "HKEY_LOCAL_MACHINE\System\CurrentControlSet\" & _ "Control\TimeZoneInformation\ActiveTimeBias"
随机推荐
- PHP实现扎金花游戏之大小比赛的方法
- 手机端点击图片放大特效PhotoSwipe.js插件实现
- javascript下阻止表单重复提交、防刷新、防后退
- perl操作符详细说明
- Swift让输入框跟随键盘弹起避免输入输入法挡住输入框问题
- Repeater控件绑定的三种方式
- C#设置WinForm中DataGrid列的方法(列宽/列标题等)
- 用 Composer构建自己的 PHP 框架之构建路由
- 30分钟学会用PHP写带数据库的简单通讯录第1/3页
- 浅析IE10兼容性问题(frameset的cols属性)
- LINUX 生产环境搭建推荐教程
- asp.net新闻列表生成静态页之批量和单页生成
- 三个不常见的 HTML5 实用新特性简介
- linux shell实现随机数几种方法分享(date,random,uuid)
- java运行shell脚本方法示例
- nginx:413 Request Entity Too Large的处理办法--修改 PHP上传文件大小
- jQuery排序插件tableSorter使用方法
- Vee-Validate的使用方法详解
- 微信小程序 底部导航栏目开发资料
- Ubuntu下开启Apache对.htaccess 的支持