<script>
<!--
function getXML(URL) {
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.Open("GET",URL, false);
xmlhttp.Send("");
var result = bytes2BSTR(xmlhttp.responseBody);
return result;
}
//-->
</script><script language="vbscript">
Function bytes2BSTR(vIn) Dim strReturn,i,ThisCharCode,innerCode,Hight8,Low8,NextCharCode
strReturn = ""

For i = 1 To LenB(vIn)
ThisCharCode = AscB(MidB(vIn,i,1))
If ThisCharCode < &H80 Then
strReturn = strReturn & Chr(ThisCharCode)
Else
NextCharCode = AscB(MidB(vIn,i+1,1))
strReturn = strReturn & Chr(CLng(ThisCharCode) * &H100 + CInt(NextCharCode))
i = i + 1
End If
Next

bytes2BSTR = strReturn

End Function
</script><button onclick=alert(getXML("http://www.5inet.net/article/xml/1024.xml"))>获取xml</button>

解决方案 »

  1.   

    http://www.csdn.net/expert/topic/749/749358.xml?temp=.3731348
      

  2.   

    http://www.csdn.net/expert/topic/749/749358.xml?temp=.3731348
      

  3.   

    孟子兄:
    不行呀,不用那个转换函数还可以显示alert一大堆,用了以后只剩下"<"一个字符了
      

  4.   

    不是在meta前加就有用的。。
    输出前用
    <?
    header("content-type","text/html; charset=gb2312");
    ?>
      

  5.   

    ±i&frac34;&#484;&#894;¤&copy;
    就是这种乱麻。各位分析大概是什么原因造成的
      

  6.   

    ±i&frac34;&#484;&#894;¤&copy;
    就是这种乱麻。各位分析大概是什么原因造成的
      

  7.   

    謝謝saucer(思归) 問題解決了,答案是下面這樣的:
    alert(bytes2BSTR(XH.responseBody));
    既要用到轉換函數,也要用到responseBody請問一下這裡responseBody和responseText爲什麽會不同?
      

  8.   

    今天才發現csdn上並不能把所有的字符原本的顯示出來因爲上面所帖的亂碼很多都被csdn轉換了,hehe
      

  9.   

    我現在是越來越大意了上面各位的答案本來就是responseBody:)