Here you can find the source of getChildByName(Node node, String name)
Parameter | Description |
---|---|
node | The parent node. |
name | The name of the child. |
node
named name
.
public static Node getChildByName(Node node, String name)
//package com.java2s; //License from project: Creative Commons License import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { /**// w ww . ja v a 2s. com * Returns the first child of a node with a specified name. * * @param node The parent node. * @param name The name of the child. * @return The first child of <code>node</code> named <code>name</code>. */ public static Node getChildByName(Node node, String name) { try { NodeList list = node.getChildNodes(); for (int i = 0; i < list.getLength(); i++) { if (list.item(i).getNodeName().equals(name)) { return list.item(i); } } return null; } catch (Exception e) { return null; } } }