Java Utililty Methods XML Attribute Copy

List of utility methods to do XML Attribute Copy

Description

The list of methods to do XML Attribute Copy are organized into topic(s).

Method

voidcopyAttributes(Element fromEl, Element toEl)
copy all attributes form one element to another
for (int a = 0; a < fromEl.getAttributes().getLength(); a++) {
    Attr at = (Attr) fromEl.getAttributes().item(a);
    toEl.setAttribute(at.getName(), at.getValue());
voidcopyAttributes(final Element destElement, final Element srcElement)
copy Attributes
final NamedNodeMap attribs = srcElement.getAttributes();
for (int i = 0; i < attribs.getLength(); i++) {
    final Attr attr = (Attr) attribs.item(i);
    final String uri = attr.getNamespaceURI();
    final String qname = attr.getName();
    final String value = attr.getNodeValue();
    if (uri == null && qname.startsWith("xmlns")) {
    } else {
...
voidcopyAttributes(Node from, Node to)
copy Attributes
NamedNodeMap map = from.getAttributes();
for (int i = 0; i < map.getLength(); i++) {
    Node attr = map.item(i);
    addAttribute(to, attr.getNodeName(), attr.getNodeValue());
voidcopyAttributes(Node sourceNode, Element visualElement)
Copies all attributes from source node to visual node.
NamedNodeMap namedNodeMap = sourceNode.getAttributes();
for (int i = 0; i < namedNodeMap.getLength(); i++) {
    Node attribute = namedNodeMap.item(i);
    visualElement.setAttribute(attribute.getNodeName(), attribute.getNodeValue());
voidcopyAttributes(SOAPElement target, Element source)
copy Attributes
NamedNodeMap attrs = source.getAttributes();
for (int i = 0; i < attrs.getLength(); i++) {
    Node nd = attrs.item(i);
    target.setAttribute(nd.getNodeName(), nd.getNodeValue());