Java XML Element Get by Name getElementByTagName(Element aParent, String aName)

Here you can find the source of getElementByTagName(Element aParent, String aName)

Description

get Element By Tag Name

License

Apache License

Declaration

public static Element getElementByTagName(Element aParent, String aName) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

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

public class Main {
    public static Element getElementByTagName(Element aParent, String aName) {
        Node child = aParent.getFirstChild();
        while (child != null) {
            if (child instanceof Element && ((Element) child).getTagName().equals(aName)) {
                return (Element) child;
            }//  w  w  w  . ja va 2 s . co  m
            child = child.getNextSibling();
        }
        return null;
    }
}

Related

  1. getElementByName(Element parent, String nodeName)
  2. getElementByTag(HTMLDocument htmlDoc, int offset, Tag tag)
  3. getElementByTagAndName(Document document, String tagName, String elementName)
  4. getElementByTagName(Document doc, String eleName)
  5. getElementByTagName(Document document, String tagName)
  6. getElementByTagName(Element parent, String elementName)
  7. getElementByTagName(Element parent, String elementName)
  8. getElementByTagNameWithParents(Element n, String... elementName)
  9. getElementDateValue(Document document, Element parent, String string)