Java XML Element Get by Name getElementByTagName(Document doc, String eleName)

Here you can find the source of getElementByTagName(Document doc, String eleName)

Description

get Element By Tag Name

License

Open Source License

Declaration

public static Element getElementByTagName(Document doc, String eleName) 

Method Source Code

//package com.java2s;

import org.w3c.dom.Document;
import org.w3c.dom.Element;

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

public class Main {

    public static Element getElementByTagName(Document doc, String eleName) {

        NodeList nl = doc.getElementsByTagName(eleName);
        if (null == nl) {
            return null;
        }//from w w w  .  j  a  va2  s.c o  m
        Node item = nl.item(0);
        return (Element) item;
    }
}

Related

  1. getElementByName(Document document, String name)
  2. getElementByName(Element eParent, String elementName)
  3. getElementByName(Element parent, String nodeName)
  4. getElementByTag(HTMLDocument htmlDoc, int offset, Tag tag)
  5. getElementByTagAndName(Document document, String tagName, String elementName)
  6. getElementByTagName(Document document, String tagName)
  7. getElementByTagName(Element aParent, String aName)
  8. getElementByTagName(Element parent, String elementName)
  9. getElementByTagName(Element parent, String elementName)