发新话题
打印

为什么用getNodeValue()不能返回该Node的值

为什么用getNodeValue()不能返回该Node的值

其Node用getNodtType()返回为1

TOP

并不是你的文档问题,  
你所要的节点的值,并不能直接用getNodeValue();  
它的值是放在它的第一个子节点上,  
先用getChildNode();再用getNodeValue();

TOP

to    fuladuo(龙人):  
我已经解释了,要获得text  node的内容,就必须:  

2。假设有一个textnode  a,你用a.getNodeValue()是得不到<a></a>间的东西的,你要获取它的唯一子节点,再getNodeValue  

NodeList  nodes  =  a.getChildNode();  
String  text  =  nodes.item(0).getNodeValue();  

和  tanjun_007(军军)  说得一样。

TOP

发新话题