爱问知识人 爱问教育 医院库

报错“无法显示XML页”如何解决?

首页

报错“无法显示XML页”如何解决?

报错“无法显示XML页”如何解决?

提交回答

全部答案

    2018-10-28 09:26:33
  •   具体内容如下:在我们从数据库读取数据,并以XML格式显示的时候,电脑就有提示出hd,category,subsort等没有关闭,但是检查已经关闭了,所以问题不出在这里,那我们就一起来找找吧,首先看看源代码。%response。ContentType= text/xmlResponse。
      CharSet = GB2312Response。Expires = 0Response。write ?xml version=1。0 encoding=UTF-8 ?Response。write vbcrlfhdResponse。write vbcrlfvbTabcategoryResponse。
      write vbcrlfvbTabvbTabsubsort‘连接数据库的语句省略do while not rs。eofresponse。write vbcrlfvbTabvbTabvbTabitemresponse。write vbcrlfvbTabvbTabvbTabvbTabidrs(id)/idresponse。
      write vbcrlfvbTabvbTabvbTab/itemlooprs。close()set rs=nothingresponse。write vbcrlfvbTabvbTab/subsortresponse。write vbcrlfvbTab/categoryresponse。
      write vbcrlf/hdResponse。End() %看了一下代码,发现代码中含有很多【 ' 】特殊符号,而真正在XML格式文件中,不能含有这些特殊符号,需要进行XmlEncode编码,改了之后我们在看看代码:Function XMLEncode(var)On Error Resume NextDim strTmpIf (IsNull(var)) Thenvar = End IfIf (VarType(var) = 11) ThenIf (var) ThenstrTmp = 1ElsestrTmp = 0End IfElsestrTmp = CStr(var)strTmp = Replace(strTmp, , )strTmp = Replace(strTmp, , )strTmp = Replace(strTmp, , )strTmp = Replace(strTmp, , )strTmp = Replace(strTmp, ', ')End IfXMLEncode = strTmpEnd FunctionFunction XMLDecode(str)Dim temptemp=replace(str,,)temp=replace(temp,,)temp=replace(temp,,)temp=replace(temp,,)temp=replace(temp,',')XMLDecode = tempEnd FunctionResponse。
      Write XmlEndode(rs(字段名字))除此之外,如果还有其他问题,我们还可以改动一下代码:Response。write “?xml version=”1。0″” encoding=”UTF-8″” ?改成Response。write “?xml version=”1。
      0″” encoding=”GB2312″” ?Response。ClearResponse。write “?xml version=”1。0″” encoding=”GB2312″” ?另外,写成Response。write vbCrlf vbTab vbTab “subsort将一些代码改成这样,更利于我们观察,同时也更好的显示出来。
      

    朱***

    2018-10-28 09:26:33

类似问题

换一换

相关推荐

正在加载...
最新问答 推荐信息 热门专题 热点推荐
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200

热点检索

  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
返回
顶部
帮助 意见
反馈

确定举报此问题

举报原因(必选):