Java XML First Child Element getFirstChildElement(final Node parent, final String elemName)

Here you can find the source of getFirstChildElement(final Node parent, final String elemName)

Description

get First Child Element

License

Apache License

Declaration

public static Element getFirstChildElement(final Node parent, final String elemName) 

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 getFirstChildElement(final Node parent, final String elemName) {
        for (Node child = parent.getFirstChild(); child != null; child = child.getNextSibling()) {
            final short nodeType = child.getNodeType();
            if (nodeType == Node.ELEMENT_NODE) {
                final String nodeName = child.getNodeName();
                if (nodeName.equals(elemName)) {
                    return (Element) child;
                }//from ww w .  j a va 2 s  .  c om
            }
        }
        return null;
    }
}

Related

  1. getFirstChildElement(Element parent, String tagName)
  2. getFirstChildElement(Element parent, String tagName)
  3. getFirstChildElement(Element parentElem)
  4. getFirstChildElement(Element root)
  5. getFirstChildElement(final Node node)
  6. getFirstChildElement(Node n)
  7. getFirstChildElement(Node n, String ns, String localName)
  8. getFirstChildElement(Node node)
  9. getFirstChildElement(Node node)