public void copyAttributes(Element fromElement, Element toElement) {
        NamedNodeMap attributes = fromElement.getAttributes();
        for(int i=0; i<attributes.getLength(); i++) {
            Node item = attributes.item(i);
            toElement.setAttribute(item.getNodeName(), item.getNodeValue());
        }
    }