我是用脚本宿主的。
var http=new ActiveXObject("Microsoft.XMLHTTP");
http.open("GET","http://www.sohu.com/",false);
http.onreadystatechange=onhandle;
http.setRequestHeader("Content-Type","text/xml");
http.send();function onhandle()
{
  if (http.readyState == 4 && http.status == 200) 
  { 
      WScript.Echo(http.responseText); 
      WScript.Echo(http.responseXML.xml);
  } 
}
这里的http.responseText怎么是html格式的字符串,怎么让他返回xml格式的字符串啊。responseXML返回也为空,晕死了。帮帮忙吧。谢谢啦 

解决方案 »

  1.   

    responseXML 这个为空了,说明你后台返回值有问题。
      

  2.   

    后台试一下:Response.ContentType = "text/xml";
      

  3.   


    document.write(http.responseXML); /*undefined 说明没有给responseXML赋值*/
    document.write(typeof(http.responseXML.xml));/*string 说明该属性是存在的*/
    document.write(http.responseXML.xml=="");/*true 说明xml属性值为空*/
      

  4.   

    response.setContentType("text/xml");
    response.getWriter().print("xml字符串");
    return null;
      

  5.   

    html格式的字符串是否返回了页面,不要返回页面
    response.setContentType("text/xml");
    response.getWriter().print("xml字符串");//只需要输出你要的信息
    return null;//不用返回
      

  6.   

    我是用脚本宿主的。怎么用后台:Response.ContentType = "text/xml";
      

  7.   

    我用的脚本宿主,document 用不了
    我用的echo
    WScript.Echo(typeof(http.responseXML.xml)); 返回string,说明属性存在
    WScript.Echo(http.responseXML.xml=="");这个返回的是 -1,怎么是 -1???
    再次晕
      

  8.   

    返回什么应该是请求的页面中设定contenttype吧
      

  9.   

    哦(http.responseXML.xml=="")=-1,也表示为真,也就是说http.responseXML的确是什么都没有收到,改怎么收到返回页面的xml啊,谢谢各位。我再次强调是脚本宿主