Java XML Attribute Get getAttributes(final Node node, final String[] attributeNames)

Here you can find the source of getAttributes(final Node node, final String[] attributeNames)

Description

get Attributes

License

LGPL

Declaration

public static String[] getAttributes(final Node node, final String[] attributeNames) 

Method Source Code

//package com.java2s;
//License from project: LGPL 

import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;

public class Main {
    public static String[] getAttributes(final Node node, final String[] attributeNames) {
        final String[] valueList = new String[attributeNames.length];
        final NamedNodeMap attMap = node.getAttributes();
        Node tmpNode = null;/*w w  w. j  a va  2s  . co m*/
        for (int i = 0; i < attributeNames.length; i++) {
            try {
                tmpNode = attMap.getNamedItem(attributeNames[i]);
                valueList[i] = tmpNode.getNodeValue();
            } catch (Exception e) {
                valueList[i] = "";
            }
        } // next attribute
        return valueList;
    }
}

Related

  1. getAttributes(Element element)
  2. getAttributes(Element element)
  3. getAttributes(Element root, String elementName, String[] wantedAttributes)
  4. getAttributes(final Element el)
  5. getAttributes(final Element element)
  6. getAttributes(Node element)
  7. getAttributes(Node n)
  8. getAttributes(Node node)
  9. getAttributes(Node node)