Exemple #1
0
 private void removeNodes(NodeList nl) {
   int count = nl.getLength();
   for (int i = 0; i < count; i++) {
     Node node = nl.item(i);
     Node parent = node.getParentNode();
     if (parent == null) continue;
     parent.removeChild(node);
   }
 }
Exemple #2
0
 private void setXmlEntry(Document doc, Node opSet) {
   NodeList targetNodes = findNodes(doc, opSet);
   NodeList valueNodes = getValueNodes(opSet);
   if (targetNodes == null) {
     return;
   }
   int targetNodesCount = targetNodes.getLength();
   for (int i = 0; i < targetNodesCount; i++) {
     Node target = targetNodes.item(i);
     for (Node child; (child = target.getFirstChild()) != null; target.removeChild(child)) ;
     appendNodes(doc, target, valueNodes);
   }
 }
Exemple #3
0
 private void replaceXmlEntry(Document doc, Node opReplace) {
   NodeList targetNodes = findNodes(doc, opReplace);
   NodeList valueNodes = getValueNodes(opReplace);
   if (targetNodes == null) {
     return;
   }
   int targetNodesCount = targetNodes.getLength();
   for (int i = 0; i < targetNodesCount; i++) {
     Node target = targetNodes.item(i);
     Node parent = target.getParentNode();
     if (parent == null) continue;
     parent.removeChild(target);
     appendNodes(doc, parent, valueNodes);
   }
 }