Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/*L
 * Copyright Washington University in St. Louis, SemanticBits, Persistent Systems, Krishagni.
 *
 * Distributed under the OSI-approved BSD 3-Clause License.
 * See http://ncip.github.com/commons-module/LICENSE.txt for details.
 */

import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

public class Main {
    /**
     * This method return role name from xml file.
     * @param element String- privilege Element
     * @param elementName -Element name for which value has to be return
     * @return String Role name
     */
    public static String getElementValue(Element element, String elementName) {
        String roleName = "";
        NodeList elementList = element.getElementsByTagName(elementName);
        Element ele = (Element) elementList.item(0);
        NodeList valueNodeList = ele.getChildNodes();
        Node node = ((Node) valueNodeList.item(0));
        if (node != null) {
            roleName = node.getNodeValue();
        }
        return roleName;
    }
}