Here you can find the source of getSiblingNamed(Element element, String name)
public static Element getSiblingNamed(Element element, String name)
//package com.java2s; // Metawidget (licensed under LGPL) import org.w3c.dom.Element; import org.w3c.dom.Node; public class Main { /**/*from ww w.j ava2 s. c om*/ * Gets the next sibling to the given element with the given name. * * @return the next sibling, or null if no such sibling */ public static Element getSiblingNamed(Element element, String name) { if (element == null) { return null; } Node node = element; while (true) { node = node.getNextSibling(); if (node == null) { return null; } if (!(node instanceof Element)) { continue; } if (name.equals(node.getLocalName())) { return (Element) node; } } } }