Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import org.w3c.dom.Attr;

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

public class Main {
    /**
     * Method getAttr.
     * <br>Returns the Attribute with the given attrName at node
     * <br>Example<br>
     * This example returns the 'state' attribute from the address node:
     *      Attr state = getAttr(address,"state")
     * @param node - Node to search
     * @param attrName - Name of the attribute to find
     * @return Attr - Attribute found
     */
    public static Attr getAttr(Node node, String attrName) {
        NamedNodeMap attrs = node.getAttributes();
        return (Attr) attrs.getNamedItem(attrName);
    }
}