Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;

public class Main {
    public static String getAttributeValue(Element start, String attrName) {
        if (start.getNodeType() == Element.ELEMENT_NODE) {
            NamedNodeMap startAttr = start.getAttributes();
            for (int i = 0; i < startAttr.getLength(); i++) {
                Node attr = startAttr.item(i);
                if (attrName.equals(attr.getNodeName().trim()))
                    return attr.getNodeValue().trim();
            }
            return null;
        } else
            return null;
    }
}