Java XML Element Get by Name getElement(Element parentElement, String nodeName)

Here you can find the source of getElement(Element parentElement, String nodeName)

Description

get Element

License

Open Source License

Declaration

public static Element getElement(Element parentElement, String nodeName) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import org.w3c.dom.Element;

import org.w3c.dom.NodeList;

public class Main {
    public static Element getElement(Element parentElement, String nodeName) {
        NodeList list = parentElement.getElementsByTagName(nodeName);
        if (list == null || list.getLength() == 0) {
            return null;
        }//from  ww  w .ja  v a2s  . c o  m
        return (Element) list.item(0);
    }
}

Related

  1. getElement(Element parent, String elementName)
  2. getElement(Element parent, String elementName)
  3. getElement(Element parent, String localname, int position)
  4. getElement(Element parent, String tagName)
  5. getElement(Element parent, String tagName)
  6. getElement(Node parent, int index)
  7. getElement(String elementName, Element parentElement)
  8. getElement(String name, int index, Element parent)
  9. getElementByName(Document document, String name)