Here you can find the source of getElementValue(Element element, String elementName)
Parameter | Description |
---|---|
element | String- privilege Element |
elementName | -Element name for which value has to be return |
public static String getElementValue(Element element, String elementName)
//package com.java2s; /*L// w ww. j a v a2 s . c om * 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; } }