The list of methods to do XML Node Clone are organized into topic(s).
Node
cloneNode(Node node) Currently only use by GIFStreamMetadata and GIFImageMetadata
if (node == null) {
return null;
IIOMetadataNode newNode = new IIOMetadataNode(node.getNodeName());
if (node instanceof IIOMetadataNode) {
IIOMetadataNode iioNode = (IIOMetadataNode) node;
Object obj = iioNode.getUserObject();
if (obj instanceof byte[]) {
...
Node
cloneNode(Node node, Document doc) Clones the given DOM node into the given DOM document.
Node clone = null;
switch (node.getNodeType()) {
case Node.ELEMENT_NODE:
clone = doc.createElement(node.getNodeName());
NamedNodeMap attrs = node.getAttributes();
for (int i = 0; i < attrs.getLength(); i++) {
Node attrNode = attrs.item(i);
Attr attrClone = doc.createAttribute(attrNode.getNodeName());
...
Node
cloneNode(Node node, Document target, boolean deep) Clone given Node into target Document.
if (target == null || node.getOwnerDocument() == target)
return node.cloneNode(deep);
else {
Node newNode;
int nodeType = node.getNodeType();
switch (nodeType) {
case Node.ATTRIBUTE_NODE:
newNode = target.createAttribute(node.getNodeName());
...
void
copyInto(Node src, Node dest) Copies the source tree into the specified place in a destination tree.
Document factory = dest.getOwnerDocument();
boolean domimpl = factory instanceof DocumentImpl;
Node start = src;
Node parent = src;
Node place = src;
while (place != null) {
Node node = null;
int type = place.getNodeType();
...
Document
copyNode(Node source) Copies node and all its children to the new document as root element in the new document
if (source == null) {
return null;
Document sourceDoc = (source.getNodeType() == Node.DOCUMENT_NODE) ? (Document) source
: source.getOwnerDocument();
Node rootNode = (source.getNodeType() == Node.DOCUMENT_NODE) ? sourceDoc.getDocumentElement() : source;
Preconditions.checkState(sourceDoc != null);
DOMImplementation domImpl = sourceDoc.getImplementation();
...
Node
copyNode(Node source, Node dest) Copy one node to another node.
if (source.getNodeType() == Node.TEXT_NODE) {
Text tn = dest.getOwnerDocument().createTextNode(source.getNodeValue());
return tn;
Node attr = null;
NamedNodeMap attrs = source.getAttributes();
if (attrs != null) {
for (int i = 0; i < attrs.getLength(); i++) {
...