ASP常用函數(shù):XMLEncode
輸出RSS和XML時(shí)經(jīng)常用到,和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
%>
還有個(gè):
<%
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
%>
相關(guān)文章
asp中靜態(tài)頁(yè)面實(shí)現(xiàn)方法
實(shí)現(xiàn)靜態(tài)html頁(yè)面有幾種方法,一種是利用了isapi_rewrite進(jìn)行動(dòng)態(tài)鏈接重寫(xiě)html靜態(tài)網(wǎng)址,一種是利用了asp程序來(lái)實(shí)例,如是實(shí)例2,3哦,還有一種就是真實(shí)的靜態(tài)頁(yè)面,看實(shí)例四。2007-09-09asp,VBscript語(yǔ)法錯(cuò)誤,史上最全最詳細(xì)最精確
asp,VBscript語(yǔ)法錯(cuò)誤,史上最全最詳細(xì)最精確...2007-03-03javascript asp教程第八課--request對(duì)象
javascript asp教程第八課--request對(duì)象...2007-03-03asp下DateDiff 函數(shù)參數(shù)說(shuō)明
asp下DateDiff 函數(shù)參數(shù)說(shuō)明...2007-04-04學(xué)習(xí)ASP和編程的28個(gè)觀點(diǎn)
學(xué)習(xí)ASP和編程的28個(gè)觀點(diǎn)...2007-02-02ASP編程入門(mén)進(jìn)階(十八):FSO組件之文件操作(上)
ASP編程入門(mén)進(jìn)階(十八):FSO組件之文件操作(上)...2007-01-01