Copy the attribues on one element to the other
import org.w3c.dom.Attr;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
public class Utils {
public static void copyAttributes(Element from, Element to) {
NamedNodeMap attributes = from.getAttributes();
for (int i = 0; i < attributes.getLength(); i++) {
Attr node = (Attr) attributes.item(i);
to.setAttributeNS(node.getNamespaceURI(), node.getName(), node.getValue());
}
}
}
Related examples in the same category