List of utility methods to do XML Node Append
Comment | addComment(Node node, String comment) add Comment Document doc = null; if (node.getNodeType() == Node.DOCUMENT_NODE) { doc = (Document) node; } else { doc = node.getOwnerDocument(); Comment e = doc.createComment(comment); node.appendChild(e); ... |
void | addDescendants(Node node, List Adds descendant elements of a node to a list. NodeList children = node.getChildNodes(); int numChildren = children.getLength(); for (int i = 0; i < numChildren; i++) { Node child = children.item(i); if (child.getNodeType() == Node.ELEMENT_NODE) { descendants.add(child); addDescendants(child, descendants); |
void | addImageSource(Node test, List holder) add Image Source if (test.getNodeType() != Node.ELEMENT_NODE) return; Element RealTest = (Element) test; Node SourceNode = RealTest.getAttributeNode("SRC"); if (SourceNode == null) return; String text = SourceNode.getNodeValue(); if (text == null || text.length() == 0) ... |
void | addNodeValue(Node node, String name, boolean value) add Node Value addNodeValue(node, name, value ? "true" : "false"); |
Node | addValue(Node node, String value) Add a value to the specified node final Node newNode; if (node instanceof Document) newNode = ((Document) node).createTextNode(value); else newNode = node.getOwnerDocument().createTextNode(value); if (newNode != null) node.appendChild(newNode); return newNode; ... |
void | appendChild(Node parent, Node child) Checks if child element has same owner document before appending to the parent, and imports it to the parent's document if necessary. Document ownerDoc = getOwnerDocument(parent); if (child.getOwnerDocument() != ownerDoc) { parent.appendChild(ownerDoc.importNode(child, true)); } else { parent.appendChild(child); |
Node | appendForeignChild(Node node, Node foreignChild) append Foreign Child return node.appendChild(node.getOwnerDocument().importNode(foreignChild, true));
|
boolean | canAppend(Node node, Node parentNode) Checks if the node can be appended on the given parent node if (node == null || parentNode == null || node == parentNode || isAncestorOf(node, parentNode)) { return false; return true; |