Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

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

public class Main {

    public static String getNodeAttributeValue(String attrName, Node node) {
        if (node == null || attrName == null) {
            return null;
        }

        NamedNodeMap attrs = node.getAttributes();
        if (attrs == null) {
            return null;
        }

        Node attrNode = attrs.getNamedItem(attrName);
        if (attrNode != null) {
            return attrNode.getNodeValue();
        } else {
            return null;
        }
    }
}