Java XML Attribute Copy copyAllAttributes(Element from, Element to)

Here you can find the source of copyAllAttributes(Element from, Element to)

Description

copy All Attributes

License

Open Source License

Declaration

public static void copyAllAttributes(Element from, Element to) 

Method Source Code

//package com.java2s;

import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Attr;
import org.w3c.dom.Element;

public class Main {
    public static void copyAllAttributes(Element from, Element to) {
        NamedNodeMap attrs = from.getAttributes();
        int attrCount = attrs.getLength();

        for (int i = 0; i < attrCount; ++i) {
            Attr attr = (Attr) attrs.item(i);

            to.setAttributeNS(attr.getNamespaceURI(), /*QName*/ attr.getName(), attr.getValue());
        }/*from  w  w w. j a va  2  s .  co  m*/
    }
}

Related

  1. cloneAttribute(Node source, Node destination, String attrName)
  2. cloneAttributes(Element element, Element targetElement)
  3. copyAllAttributes(Element source, Element dest, Set ignore)
  4. copyAttribute(Element source, String srcattr, Element dest, String destattr)
  5. copyAttribute(Element sourceElement, String sourceAttrName, Element visualElement, String visualAttrName)
  6. copyAttributeNodes(Element source, Element target)