【发布时间】:2015-05-15 11:51:40
【问题描述】:
我的代码是这样的
var tariffdate = PriceSheet.children('TariffEffDate')[1].text;
我希望在TariffEffDate 标记内获取数据。但它给了我undefined。
我可以得到<TariffEffDate>1999-01-01T00:00:00</TariffEffDate> 作为代码的结果
console.log(PriceSheet.children('TariffEffDate')[1])
但是当我添加.text 以获取此节点内的数据时,它给了我undefined。
谁能指出我在这里做错了什么?
【问题讨论】:
-
您需要使用
.nodeValue而不是.textIIRC。 -
@h2ooooooo 我试过了,结果为空
-
Someone else 必须使用
[1].firstChild.nodeValue而不是[1].nodeValue。也许这会解决它? -
@h2ooooooo 解决了这个问题,你可以添加它作为答案
标签: javascript