Java examples for XML:DOM Element
Get the previous sibling XML element.
//package com.java2s; import org.w3c.dom.Element; import org.w3c.dom.Node; public class Main { /**/*www . j a v a 2 s . co m*/ * Get the previous sibling element. * * @param node The start node. * @return The previous sibling element or {@code null}. */ public static Element getPreviousSiblingElement(Node node) { Node n = node.getPreviousSibling(); while (n != null && n.getNodeType() != Node.ELEMENT_NODE) { n = n.getPreviousSibling(); } return (Element) n; } }