<?xml version="1.0" encoding="UTF-8"?>
<books>
<book id="ABC-345">
<author> Frankie </author>
<price> 50 </price>
<chapters>
<chapter id="1"> Hello World </chapter>
<chapter id="2"> Hello China </chapter>
<chapter id="3"> Hello Beijing </chapter>
</chapters>
</book>
</books>
bookNode = doc.getElementsByTagName("book").item(0);
要获得author元素里面的Frankie文本节点为什么要这样写?
bookNode.getFirstChild().getNextSibling().getFirstChild().getNodeValue()
为什么不是这样呢?
bookNode.getFirstChild().getFirstChild().getNodeValue();
我认为book的第一个字节点就是author, author的字节点就是Frankie这个文本节点, 接着在Frankie这个TextNode上面再执行getNodeValue()不就获得了Frankie的值了吗?Create By Any-Extract(WL-AE) 数据挖掘论坛