Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import org.w3c.dom.Element;

public class Main {
    public static String getAttributeFromElement(Element element, String name, String attributeName) {
        String result = null;
        Element nameElement = (Element) element.getElementsByTagName(name).item(0);
        if (nameElement != null) {
            result = nameElement.getAttribute(attributeName).toString();
        }
        if (result != null && result.length() == 0) {
            result = null;
        }
        return result;
    }

    public static String getAttributeFromElement(Element element, String attributeName) {
        String result = null;
        if (element != null) {
            result = element.getAttribute(attributeName).toString();
        }
        if (result != null && result.length() == 0) {
            result = null;
        }
        return result;
    }
}