getChildNodes
public NodeList getChildNodes()
A NodeList that contains all children of this node. If there are no children, this is a NodeList containing no nodes. 先返回所有的子节点
然后遍历它,根据节点的类型判断ELEMENT_NODE
public static final short ELEMENT_NODE
就可以过滤掉Text Node了
public NodeList getChildNodes()
A NodeList that contains all children of this node. If there are no children, this is a NodeList containing no nodes. 先返回所有的子节点
然后遍历它,根据节点的类型判断ELEMENT_NODE
public static final short ELEMENT_NODE
就可以过滤掉Text Node了
又不能访问下面的数据, 两难哪!我是想空格就不产生节点,Xerces C 2.2.0 有办法么?
解析器支持的话 直接打开一个开关就行(但据我推测Xerces C是没有这样的开关的)。
不然的话,要么在处理过程中记得过滤结点;
要么先将整个tree “预处理”一下,剔除所有这些空白结点,再进行你需要的处理;
但是我社了false,却没有起作用
setIgnoringElementContentWhitespace()确定是否忽略元素内容中的空白。
但是(JAXP中),这里的IgnoringElementContentWhitespace,需要由DTD来定义。否则,它无法确定哪些空白使可忽略的。