Here you can find the source of getNextElement(Node node)
Parameter | Description |
---|---|
node | the pareent XML node |
public static Node getNextElement(Node node)
//package com.java2s; /*L/* w w w .j av a 2 s . c o m*/ * Copyright SAIC, SAIC-Frederick. * * Distributed under the OSI-approved BSD 3-Clause License. * See http://ncip.github.com/caadapter/LICENSE.txt for details. */ import org.w3c.dom.Node; public class Main { /** * Get a sibling XML element of a given node. For example, with the following structure * <node1> * <node2> * <node3> * getNextElement(node2) will return a reference to <node3> * * @param node the pareent XML node * @return Node the next XML sibling element. */ public static Node getNextElement(Node node) { Node child = node.getNextSibling(); if (child == null) return null; if (child.getNodeType() == Node.ELEMENT_NODE) return child; while (child != null) { if (child.getNodeType() == Node.ELEMENT_NODE) return child; child = child.getNextSibling(); } return null; } }