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); } }
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); } }
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); } }
/** * @webref xml:method * @brief Removes the specified child */ public void removeChild(XML kid) { node.removeChild(kid.node); children = null; // TODO not efficient }