List of usage examples for org.w3c.dom Node removeChild
public Node removeChild(Node oldChild) throws DOMException;
oldChild
from the list of children, and returns it. From source file:Main.java
public static void moveDown(Node currentN) { Node nextSibling = findNextElement(currentN, false); Node nextNextSibling = findNextElement(nextSibling, false); Node parent = currentN.getParentNode(); parent.removeChild(currentN); if (nextNextSibling != null) { parent.insertBefore(currentN, nextNextSibling); } else//from w w w .j a va 2 s . co m parent.appendChild(currentN); }
From source file:Main.java
public static void moveUp(Node currentN) { Node prevSibling = findPreviousElement(currentN, false); if (prevSibling != null) { Node parent = currentN.getParentNode(); parent.removeChild(currentN); parent.insertBefore(currentN, prevSibling); }/* www.j a va 2 s . c o m*/ }
From source file:Main.java
public static void moveDown(final Node currentN) { Node nextSibling = findNextElement(currentN, false); Node nextNextSibling = findNextElement(nextSibling, false); Node parent = currentN.getParentNode(); parent.removeChild(currentN); if (nextNextSibling != null) { parent.insertBefore(currentN, nextNextSibling); } else {// w ww .j av a 2 s . c om parent.appendChild(currentN); } }
From source file:Main.java
public static void moveUp(final Node currentN) { Node prevSibling = findPreviousElement(currentN, false); if (prevSibling != null) { Node parent = currentN.getParentNode(); parent.removeChild(currentN); parent.insertBefore(currentN, prevSibling); }// w w w . j a v a 2 s. com }
From source file:Main.java
/** * Removes all children of the specified node. * /*from www . ja va2s . co m*/ * @param node * the node. */ public static void removeAllChildren(Node node) { Node child; while ((child = node.getFirstChild()) != null) { node.removeChild(child); } }
From source file:Main.java
/** * based on public Java5 javadoc of org.w3c.dom.Node.setTextContent method *///from ww w .j av a2 s .c o m public static void setTextContent(Node node, final String text) { while (node.hasChildNodes()) { node.removeChild(node.getFirstChild()); } if (text != null && text.length() > 0) { Node textNode = node.getOwnerDocument().createTextNode(text); node.appendChild(textNode); } }
From source file:Main.java
/** * Method to remove all children of g:options - element * //from w w w . j a va 2 s . c om * @param doc document with children g:options * @return document without children g:options */ public static Document removeAllOptions(Document doc) { NodeList nodes = doc.getElementsByTagName("g:options"); Node node = nodes.item(0); while (node.hasChildNodes()) node.removeChild(node.getFirstChild()); return doc; }
From source file:Main.java
/** * Removes all children of the specified node. * /*from w ww . j a va 2s. c om*/ * @param node * the node. */ public static void removeAllChildren(final Node node) { Node child; while ((child = node.getFirstChild()) != null) { node.removeChild(child); } }
From source file:Main.java
public static void replaceXPathNode(Node replaceThis, Node replaceWith) throws XPathExpressionException { Node parentNode = replaceThis.getParentNode(); parentNode.insertBefore(replaceWith, replaceThis); parentNode.removeChild(replaceThis); }
From source file:Main.java
/** * Delete children elements for Node/*ww w . ja v a2 s . c om*/ */ public static void removeAllChildren(Node node) { if (node != null) { while (node.hasChildNodes()) { node.removeChild(node.getFirstChild()); } } }