Here you can find the source of getFirstSiblingNamed(Node node, String name)
node
, or node
itself, which has the given name.
Parameter | Description |
---|---|
node | A node. |
name | The name of the node we are looking for. |
null
.
public static Node getFirstSiblingNamed(Node node, String name)
//package com.java2s; import org.w3c.dom.Node; public class Main { /**//from w ww. j a v a2s . c om * 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; } }