Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//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();
                }
                lst.add(attr.getNodeValue());
            }
        }
        return lst;
    }
}