firefox childNodes[] 序号只出奇数

Da侠饶命 2009-04-26 10:46:30

<response>
<Goods>
<Number>N3706</Number>
<Name>牛仔裤</Name>
<Cost>100</Cost>
<Price>130元</Price>
<Supplier>无</Supplier>
<Remark>无</Remark>
<Stock>0件</Stock>
</Goods>
</response>


AJAX 得到XML文档
用 result[0].childNodes[0].firstChild.value 取值

在IE里面正常得到对应的值
result[0].childNodes[0].firstChild.value = N3706
result[0].childNodes[1].firstChild.value = 牛仔裤
result[0].childNodes[2].firstChild.value = 100
。。。。。。。


在fireFox里 出现问题了


result[0].childNodes[0].firstChild.value = undefined
result[0].childNodes[1].firstChild.value = N3706
result[0].childNodes[2].firstChild.value = undefined
result[0].childNodes[3].firstChild.value = 牛仔裤
result[0].childNodes[4].firstChild.value = undefined
result[0].childNodes[5].firstChild.value = 100
..........

只定义了奇数!!!!

这是为什么啊???
...全文
190 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
Da侠饶命 2009-04-27
  • 打赏
  • 举报
回复
谢谢大家,原来是这样,搞定了
xiaojing7 2009-04-26
  • 打赏
  • 举报
回复
fireFox里
换行也是一个childNode
maximus_zhang 2009-04-26
  • 打赏
  • 举报
回复
fireFox里
换行也是一个childNode
hookee 2009-04-26
  • 打赏
  • 举报
回复
以上csdn 还是自动加了空格,测试的时候标签之间的空格要去掉。
hookee 2009-04-26
  • 打赏
  • 举报
回复
连续的空字符,回车换行都是节点Node
xml源文件去掉空字符,返回如下试试看:

<response><Goods><Number>N3706</Number><Name>牛仔裤</Name><Cost>100</Cost><Price>130元</Price><Supplier>无</Supplier><Remark>无</Remark><Stock>0件</Stock></Goods></response>

52,782

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 Ajax
社区管理员
  • Ajax
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧