Java XML First Child Element firstChildNodeWithName(org.w3c.dom.Node node, String name)

Here you can find the source of firstChildNodeWithName(org.w3c.dom.Node node, String name)

Description

first Child Node With Name

License

Open Source License

Declaration

static public org.w3c.dom.Node firstChildNodeWithName(org.w3c.dom.Node node, String name) 

Method Source Code

//package com.java2s;
/* J_LZ_COPYRIGHT_BEGIN *******************************************************
* Copyright 2006-2008 Laszlo Systems, Inc.  All Rights Reserved.              *
* Use is subject to license terms.                                            *
* J_LZ_COPYRIGHT_END *********************************************************/

public class Main {
    static public org.w3c.dom.Node firstChildNodeWithName(org.w3c.dom.Node node, String name) {
        org.w3c.dom.Node foundNode = null;
        org.w3c.dom.NodeList childNodes = node.getChildNodes();
        final int n = childNodes.getLength();
        for (int i = 0; i < n; i++) {
            org.w3c.dom.Node childNode = childNodes.item(i);
            if (childNode.getNodeName().equals(name)) {
                foundNode = childNode;/*from  w  w w .j  a va  2 s  . c  o m*/
                break;
            }
        }
        return foundNode;
    }
}

Related

  1. firstChildByTagName(Node root, String tagName)
  2. firstChildElement(Element element, String childElementName)
  3. firstChildElement(Element parent)
  4. firstChildElement(Node node)
  5. firstChildElement(Node node)
  6. firstChildTextContent(Element element, String name)
  7. firstElementNodeChild(Node n)
  8. firstNamedChild(Element el, String lName)
  9. firstTextChild(Element el)