我这个怎么不能输出XML里的东东呢?
有什么错误吗?
<script language=javascript>
var orderDoc=new ActiveXObject("MSXML2.DOMDocument.3.0");
orderDoc.async=false;
orderDoc.load("xml.xml");
var items=orderDoc.selectNodes("/PolicyList/Policy/PrimaryNo");
var items1=orderDoc.selectNodes("/PolicyList/Policy/Insurance");
var PrimaryNo="",Insurance="";
for(var i=0;i<items.length;i++)
{
PrimaryNo=items[i].text;
Insurance=items1[i].text;
document.write(PrimaryNo+"  ");
document.write(Insurance+"<br />");
}
function ReadXml(doc,xpath)
{
var retval="";
var value=doc.documentElement.selectSingleNode(xpath)
if(value)retval=value.text;
return retval;
}
</script>
Ad.xml
-------------------
<?xml version='1.0' encoding='GB2312'?>
<PolicyList username="YLQ"><Policy BusinessLogic="AddFreightPolicyWeb" >
<ImgPath>images/01.jpg</ImgPath>
<ImgLink>http://www.baidu.com/</ImgLink>
<ImgText>梦:牧场小屋</ImgText>
</Policy><Policy BusinessLogic="AddFreightPolicyWeb" >
<ImgPath>images/01.jpg</ImgPath>
<ImgLink>http://www.baidu.com/</ImgLink>
<ImgText>碎玉:回眸</ImgText>
</Policy><Policy BusinessLogic="AddFreightPolicyWeb" >
<ImgPath>images/01.jpg</ImgPath>
<ImgLink>http://www.baidu.com/</ImgLink>
<ImgText>飞狐:豆花档</ImgText>
</Policy><Policy BusinessLogic="AddFreightPolicyWeb" >
<ImgPath>images/01.jpg</ImgPath>
<ImgLink>http://www.baidu.com/</ImgLink>
<ImgText>牛说不哭:烈日下的建筑工人</ImgText>
</Policy><Policy BusinessLogic="AddFreightPolicyWeb" >
<ImgPath>images/01.jpg</ImgPath>
<ImgLink>http://www.baidu.com/</ImgLink>
<ImgText>新疆瓦格:哈萨克族搭建毡房</ImgText>
</Policy><Policy BusinessLogic="AddFreightPolicyWeb" >
<ImgPath>images/01.jpg</ImgPath>
<ImgLink>http://www.baidu.com/</ImgLink>
<ImgText>松间明月:汽车文化</ImgText>
</Policy>

解决方案 »

  1.   

    我也不知道具体的。。不过昨天刚试过一次,document.write好像会覆盖以前的输出。。是不是这个问题?
    你获得的页面什么内容都没有吗?有没有说什么脚本错误?
      

  2.   

    1.你的XML文件有问题
     <?xml   version= "1.0"   encoding= "GB2312"?> 
    <PolicyList   username= "YLQ "> <Policy   BusinessLogic= "AddFreightPolicyWeb "   > 
    <ImgPath> images/01.jpg </ImgPath> 
    <ImgLink> http://www.baidu.com/ </ImgLink> 
    <ImgText> 梦:牧场小屋 </ImgText> 
    </Policy> <Policy   BusinessLogic= "AddFreightPolicyWeb "   > 
    <ImgPath> images/01.jpg </ImgPath> 
    <ImgLink> http://www.baidu.com/ </ImgLink> 
    <ImgText> 碎玉:回眸 </ImgText> 
    </Policy> <Policy   BusinessLogic= "AddFreightPolicyWeb "   > 
    <ImgPath> images/01.jpg </ImgPath> 
    <ImgLink> http://www.baidu.com/ </ImgLink> 
    <ImgText> 飞狐:豆花档 </ImgText> 
    </Policy> <Policy   BusinessLogic= "AddFreightPolicyWeb "   > 
    <ImgPath> images/01.jpg </ImgPath> 
    <ImgLink> http://www.baidu.com/ </ImgLink> 
    <ImgText> 牛说不哭:烈日下的建筑工人 </ImgText> 
    </Policy> <Policy   BusinessLogic= "AddFreightPolicyWeb "   > 
    <ImgPath> images/01.jpg </ImgPath> 
    <ImgLink> http://www.baidu.com/ </ImgLink> 
    <ImgText> 新疆瓦格:哈萨克族搭建毡房 </ImgText> 
    </Policy> <Policy   BusinessLogic= "AddFreightPolicyWeb "   > 
    <ImgPath> images/01.jpg </ImgPath> 
    <ImgLink> http://www.baidu.com/ </ImgLink> 
    <ImgText> 松间明月:汽车文化 </ImgText> 
    </Policy> 
    </PolicyList>
    应该这样 可以比较一下
      

  3.   

    orderDoc.load( "Ad.xml ");