Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import org.w3c.dom.NamedNodeMap;

public class Main {
    /**
     * Given a {@link NamedNodeMap} of XML attributes, returns the value for 
     * a particular attribute, or null if no attribute exists with this name.
     * @param attributes The attribute list.
     * @param name The name of the attribute.
     * @return The value of that attribute name, or null if no such attribute exists.
     */
    public static String getAttribute(NamedNodeMap attributes, String name) {
        if (attributes.getNamedItem(name) == null) {
            return null;
        }
        return attributes.getNamedItem(name).getNodeValue();
    }
}