Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import org.w3c.dom.*;

import java.util.LinkedList;
import java.util.List;

public class Main {
    public static List<Attr> getAttributes(Element element) {

        List<Attr> attributes = new LinkedList<Attr>();

        NamedNodeMap namedNodeMap = element.getAttributes();

        for (int i = 0; i < namedNodeMap.getLength(); i++) {
            Node node = namedNodeMap.item(i);
            if (node.getNodeType() == Node.ATTRIBUTE_NODE) {
                Attr a = (Attr) node;
                attributes.add(a);
            }
        }

        return attributes;
    }
}