最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

報(bào)錯:XML頁無法顯示,下列標(biāo)記沒有被關(guān)閉解決方法

 更新時(shí)間:2012年12月11日 10:57:09   作者:  
從數(shù)據(jù)庫讀出數(shù)據(jù),然后以XML的格式顯示數(shù)據(jù),但是提示hd,category,subsort等沒有關(guān)閉
從數(shù)據(jù)庫讀出數(shù)據(jù),然后以XML的格式顯示數(shù)據(jù),但是提示hd,category,subsort等沒有關(guān)閉,可是我已經(jīng)關(guān)閉了呀,不知道具體是什么原因造成了這個(gè)問題?
VB code:
復(fù)制代碼 代碼如下:

<%
response.ContentType= "text/xml"
Response.CharSet = "GB2312"
Response.Expires = 0
Response.write "<?xml version=""1.0"" encoding=""UTF-8"" ?>"
Response.write vbcrlf&"<hd>"
Response.write vbcrlf&vbTab&"<category>"
Response.write vbcrlf&vbTab&vbTab&"<subsort>"
‘連接數(shù)據(jù)庫的語句省略
do while not rs.eof
response.write vbcrlf&vbTab&vbTab&vbTab&"<item>"
response.write vbcrlf&vbTab&vbTab&vbTab&vbTab&"<id>"&rs("id")&"</id>"
response.write vbcrlf&vbTab&vbTab&vbTab&"</item>"
loop
rs.close()
set rs=nothing
response.write vbcrlf&vbTab&vbTab&"</subsort>"
response.write vbcrlf&vbTab&"</category>"
response.write vbcrlf&"</hd>"
Response.End()
%>

因?yàn)檩敵龅膬?nèi)容不能帶<>”‘&這幾個(gè)特殊字符,需要進(jìn)行XmlEncode編碼,如下的代碼詳情:
VBScript code:
復(fù)制代碼 代碼如下:

Function XMLEncode(var)
On Error Resume Next
Dim strTmp
If (IsNull(var)) Then
var = ""
End If
If (VarType(var) = 11) Then
If (var) Then
strTmp = "1"
Else
strTmp = "0"
End If
Else
strTmp = CStr(var)
strTmp = Replace(strTmp, "&", "&")
strTmp = Replace(strTmp, "<", "<")
strTmp = Replace(strTmp, ">", ">")
strTmp = Replace(strTmp, """", """)
strTmp = Replace(strTmp, "'", "'")
End If
XMLEncode = strTmp
End Function
Function XMLDecode(str)
Dim temp
temp=replace(str,"&","&")
temp=replace(temp,"<","<")
temp=replace(temp,">",">")
temp=replace(temp,""","""")
temp=replace(temp,"'","'")
XMLDecode = temp
End Function
Response.Write XmlEndode(rs("字段名字"))

另外,如果是文件編碼問題,則可以將:
Response.write “<?xml version=”"1.0″” encoding=”"UTF-8″” ?>”
改成
Response.write “<?xml version=”"1.0″” encoding=”"GB2312″” ?>”
另外,在開始輸出之前,需要清空內(nèi)容:
Response.Clear
Response.write “<?xml version=”"1.0″” encoding=”"GB2312″” ?>”
另外,寫成:
Response.write vbCrlf & vbTab & vbTab & “<subsort>”
更容易觀察.

相關(guān)文章

最新評論

石泉县| 洛川县| 禄丰县| 临西县| 正镶白旗| 奉化市| 偏关县| 唐海县| 芒康县| 昭平县| 会昌县| 灵石县| 太保市| 洪雅县| 吉水县| 资源县| 富阳市| 桃园县| 石首市| 盘锦市| 宝鸡市| 建阳市| 屯门区| 万全县| 桂阳县| 绥德县| 鹰潭市| 邻水| 古浪县| 平湖市| 大姚县| 静安区| 上思县| 开封市| 岚皋县| 广东省| 普兰县| 齐齐哈尔市| 麦盖提县| 古蔺县| 安塞县|