Here you can find the source of getFirstChildElement(Node node)
Parameter | Description |
---|---|
node | the pareent XML node |
public static Node getFirstChildElement(Node node)
//package com.java2s; /*L/*from w w w .j ava 2 s . co 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 first XML element of a given node. For example, with the following structure * <node1> * <node2> * getFirstChildElement(node1) will return a reference to <node2> * * @param node the pareent XML node * @return Node the first child of a given XML node. */ public static Node getFirstChildElement(Node node) { if (node == null) return null; Node child = node.getFirstChild(); 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; } }