/** * Since insertBefore caches the docElement (and, currently, docType), * removeChild has to know how to undo the cache * * REVISIT: According to the spec it is not allowed to alter neither the * document element nor the document type in any way */ public Node removeChild(Node oldChild) throws DOMException { super.removeChild(oldChild); // If remove succeeded, un-cache the kid appropriately int type = oldChild.getNodeType(); if(type == Node.ELEMENT_NODE) { docElement = null; } else if (type == Node.DOCUMENT_TYPE_NODE) { docType = null; } return oldChild; } // removeChild(Node):Node
public void setTextContent(String textContent) throws DOMException { // get rid of any existing children Node child; while ((child = getFirstChild()) != null) { removeChild(child); } // create a Text node to hold the given content if (textContent != null && textContent.length() != 0){ appendChild(ownerDocument().createTextNode(textContent)); } }
removeChild(newChild); insertBefore(newChild, refChild); return newChild;