Java XML Attribute Load getAllAttrValueByName(Node item, String name)

Here you can find the source of getAllAttrValueByName(Node item, String name)

Description

get All Attr Value By Name

License

Apache License

Declaration

public static List<String> getAllAttrValueByName(Node item, String name) 

Method Source Code


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

import java.util.ArrayList;
import java.util.List;

import org.w3c.dom.Attr;

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

public class Main {
    public static List<String> getAllAttrValueByName(Node item, String name) {
        List<String> lst = null;
        NamedNodeMap attributes = item.getAttributes();
        int numAttrs = attributes.getLength();
        for (int i = 0; i < numAttrs; i++) {
            Attr attr = (Attr) attributes.item(i);
            String attrName = attr.getNodeName();
            if (name.equals(attrName)) {
                if (lst == null) {
                    lst = new ArrayList();
                }//from   w  ww.j ava  2 s.  com
                lst.add(attr.getNodeValue());
            }
        }
        return lst;
    }
}

Related

  1. getAllAttributes(Element element)
  2. getAllAttributes(Node node)
  3. getAllAttributes(Node node)
  4. getAllAttributesAsMap(@Nullable final Element aSrcNode)
  5. getAllAttrs(Element parent, String name, List lst)
  6. getAllElementAttributes(Element element)
  7. getAllElementsWithAttrId(final Element element, final String namespace)
  8. loadAttributes(Element e)