Removing and Changing Nodes
To remove a node, you use its parent Node's removeChild method. To change it, you can either use the parent node's replaceChild operation or the node's setNodeValue operation.
To remove a node, you use its parent Node's removeChild method. To change it, you can either use the parent node's replaceChild operation or the node's setNodeValue operation.
start为根节点参数
private static void ChangeOrder(Node start, String elemName, String elemValue){
if(start.getNodeName().equals(elemName)){
start.getFirstChild().setNodeValue(elemValue);
}
for(Node child=start.getFirstChild();
child!=null;
child =child.getNextSibling()){
ChangeOrder(child,elemName,elemValue);
}
}