Here you can find the source of getFirstChildNamed(Node node, String name)
node
that has the given name, or null
.
Parameter | Description |
---|---|
node | A node. |
name | The name of the node we are looking for. |
null
.
public static Node getFirstChildNamed(Node node, String name)
//package com.java2s; import org.w3c.dom.Node; public class Main { /**/*from w ww.j av a 2 s .c om*/ * Returns the first child of <code>node</code> that has the given name, or * <code>null</code>. * * @param node * A node. * @param name * The name of the node we are looking for. * @return The first node whose name matches, or <code>null</code>. */ public static Node getFirstChildNamed(Node node, String name) { return getFirstSiblingNamed(node.getFirstChild(), name); } /** * Returns the first sibling of <code>node</code>, or <code>node</code> * itself, which has the given name. If none is found, the function returns * <code>null</code>. * * @param node * A node. * @param name * The name of the node we are looking for. * @return The first node whose name matches, or <code>null</code>. */ public static Node getFirstSiblingNamed(Node node, String name) { while (node != null && !node.getNodeName().equals(name)) { node = node.getNextSibling(); } return node; } }