Java XML Element Get Value getUniqueElement(Element root, String elementName)

Here you can find the source of getUniqueElement(Element root, String elementName)

Description

get Unique Element

License

GNU General Public License

Declaration

public static Element getUniqueElement(Element root, String elementName) 

Method Source Code

//package com.java2s;
/* ***** BEGIN LICENSE BLOCK *****
 * Version: GPL 2.0/*  w  ww.ja  v  a  2 s. c  o m*/
 *
 * The contents of this file are subject to the GNU General Public
 * License Version 2 or later (the "GPL").
 *
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 * for the specific language governing rights and limitations under the
 * License.
 *
 * The Initial Developer of the Original Code is
 *   MiniG.org project members
 *
 * ***** END LICENSE BLOCK ***** */

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

public class Main {

    public static Element getUniqueElement(Element root, String elementName) {
        NodeList list = root.getElementsByTagName(elementName);
        return (Element) list.item(0);
    }
}

Related

  1. getTrimmedText(Element element)
  2. getTrimmedTextContent(Element element)
  3. getTrimmedTextContent(Element element)
  4. getTrimmedTextValue(Element valueEle)
  5. getType(Element elementType)
  6. getUniqueSubnode(Element rootNode, String name)
  7. getValue(Element e, String tagName)
  8. getValue(Element el)
  9. getValue(Element element)