我这个怎么不能输出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>
有什么错误吗?
<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>
你获得的页面什么内容都没有吗?有没有说什么脚本错误?
<?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>
应该这样 可以比较一下