Java Utililty Methods XML Child Node Get

List of utility methods to do XML Child Node Get

Description

The list of methods to do XML Child Node Get are organized into topic(s).

Method

IIOMetadataNodegetChildNode(Node n, String name)
get Child Node
NodeList nodes = n.getChildNodes();
for (int i = 0; i < nodes.getLength(); i++) {
    Node child = nodes.item(i);
    if (name.equals(child.getNodeName())) {
        return (IIOMetadataNode) child;
return null;
...
NodegetChildNode(Node node, int index)
get Child Node
Node child = null;
NodeList children = node.getChildNodes();
if (children != null && index >= 0 && index < children.getLength()) {
    child = children.item(index);
return child;
NodegetChildNode(Node node, String childName)
get Child Node
NodeList nodes = node.getChildNodes();
for (int i = 0; i < nodes.getLength(); i++) {
    Node curNode = nodes.item(i);
    if (curNode.getLocalName() != null && curNode.getLocalName().equals(childName)) {
        return curNode;
return null;
...
NodegetChildNode(Node node, String name)
Returns the first XML child tag with the specified name.
Node child = node.getFirstChild();
while (child != null) {
    if (child.getNodeName().equals(name)) {
        return child;
    child = child.getNextSibling();
return null;
...
NodegetChildNode(Node node, String name)
get Child Node
for (int i = 0; i < node.getChildNodes().getLength(); i++) {
    String nodeName = node.getChildNodes().item(i).getNodeName();
    if (nodeName.endsWith(name))
        return node.getChildNodes().item(i);
return null;
NodegetChildNode(Node node, String name)
Returns the first XML child tag with the specified name.
Node child = node.getFirstChild();
while (child != null && !child.getNodeName().equals(name)) {
    child = child.getNextSibling();
return child;
NodegetChildNode(Node node, String nodeName)
get Child Node
if (node.getNodeType() == Node.ELEMENT_NODE) {
    NodeList nodeList = node.getChildNodes();
    for (int i = 0; i < nodeList.getLength(); i++) {
        Node n = nodeList.item(i);
        if (n.getNodeName().equals(nodeName)) {
            return n;
return null;
NodegetChildNode(Node node, String tag)
Return the child node of the specified node with the specified tag.
Node res = null;
NodeList children = node.getChildNodes();
int len = (children != null) ? children.getLength() : 0;
int i = 0;
while (i < len && res == null) {
    Node child = children.item(i);
    String nodeName = child.getNodeName();
    if (nodeName.equals(tag)) {
...
NodegetChildNode(Node parent, String childName)
Gets a named child node.
return getChildElement(parent, childName);
NodegetChildNode(Node parent, String tagName)
Get the first child with a certain tag name
NodeList children = parent.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
    Node currentNode = children.item(i);
    if (currentNode.getLocalName().equalsIgnoreCase(tagName)) {
        return currentNode;
throw new Exception("Child Node ['" + tagName + "'] not found.");
...