Here you can find the source of getChildNode(Node node, String tag)
Parameter | Description |
---|---|
node | The parent DOM node |
tag | The tag of the node |
public static Node getChildNode(Node node, String tag)
//package com.java2s; import org.w3c.dom.*; public class Main { /**/*from w w w .ja va2s . c o m*/ * Return the child node of the specified node with the specified tag. * * @param node The parent DOM node * @param tag The tag of the node * @return the child node */ public static Node getChildNode(Node node, String 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)) { res = child; } i++; } return res; } }