Java XML First Child Element getDirectChild(Node fNode, String localName, String namespace)

Here you can find the source of getDirectChild(Node fNode, String localName, String namespace)

Description

get Direct Child

License

Open Source License

Declaration

public static Node getDirectChild(Node fNode, String localName, String namespace) 

Method Source Code

//package com.java2s;
/*//from  ww  w .  j  a  v a2 s  . c  om
 This file is licensed under the terms of the Globus Toolkit Public
 License, found at http://www.globus.org/toolkit/download/license.html.
 */

import org.w3c.dom.Node;

public class Main {
    public static Node getDirectChild(Node fNode, String localName, String namespace) {
        for (Node currentChild = fNode.getFirstChild(); currentChild != null; currentChild = currentChild
                .getNextSibling()) {
            // sometimes, namespace might be null somehow
            if ((namespace == null || namespace.equalsIgnoreCase(currentChild.getNamespaceURI()))
                    && localName.equalsIgnoreCase(currentChild.getLocalName())) {
                return currentChild;
            }
        }

        return null;
    }
}

Related

  1. firstChildTextContent(Element element, String name)
  2. firstElementNodeChild(Node n)
  3. firstNamedChild(Element el, String lName)
  4. firstTextChild(Element el)
  5. getDirectChild(Node fNode, String localName, String namespace)
  6. getDirectChildElement(Element p_rootElement, String p_elementName)
  7. getDirectChildElements(Element parent)
  8. getDirectChildElements(Node fNode, String localName, String namespace)
  9. getDirectChildElementsByTag(Element node, String tag)