xml文件:
<employees>
<employee value="employee的值">
<name>Mary</name>
<sex>女</sex>
</employee>
</employees>当遍历树时,发现employee下有5个子节点,下面是打印出的节点名
节点名:#text
节点名:name
节点名:#text
节点名:sex
节点名:#text现在想请各位高手解释一下为什么会有5个子节点,如何删除其中的#text节点
<employees>
<employee value="employee的值">
<name>Mary</name>
<sex>女</sex>
</employee>
</employees>当遍历树时,发现employee下有5个子节点,下面是打印出的节点名
节点名:#text
节点名:name
节点名:#text
节点名:sex
节点名:#text现在想请各位高手解释一下为什么会有5个子节点,如何删除其中的#text节点
解决方案 »
- 想把spring当做一个工程导入到eclipse里学习源码,怎么弄呢?
- 拜个早年:祝工作顺利!麻烦大家帮我看下我写的这个java连接数据库类哪错了——?
- 请教高手一些OpenCms的使用问题
- 在线等,多应用,使用统一用户系统,本地旧的用户系统不想废弃,想两系统并用,服务端与本地的数据同步问题。
- java 动态定义变量问题
- 100分相送,一个比较令人困惑的tomcat中配置ssl的问题
- hibernate中怎样操作mysql数据库中的存放的文件?
- 如果LOCAL/REMOTE接口一起实现,怎么查找HOME接口????????进来看看
- Strut2.5.10Spring4.38Hibernate5.02整合启动服务器出错
- Eclipse
- 关于hibernate多表查询的问题
- ExcelReport监听器
{
Node current = root;
Node parent = root;
bool isLeftChild = true;
while (current.Data != key)
{
parent = current;
if (key < current.Data)
{
isLeftChild = true;
current = current.Right;
}
else
{
isLeftChild = false;
current = current.Right;
}
if (current == null)
return false;
}
if ((current.Left == null) & (current.Right == null))
if (current == root)
root = null;
else if (isLeftChild)
parent.Left = null;
else if (current.Right == null)
if (current == root)
root = current.Left;
else if (isLeftChild)
parent.Left = current.Left;
else
parent.Right = current.Right;
else if (current.Left == null)
if (current == root)
root = current.Right;
else if (isLeftChild)
parent.Left = parent.Right;
else
parent.Right = current.Right;
else
{
Node successor = GetSuccessor(current);
if (current == root)
root = successor;
else if (isLeftChild)
parent.Left = successor;
else
parent.Right = successor;
successor.Left = current.Left;
}
return true;
}
需要注意的是比如
<name>Mary </name>
是两个节点,中间的Mary是一个文本节点,即#text, 他是属于name节点的子节点。
可以采用这条语句过滤 if(node.getNodeType() != Node.TEXT_NODE)