public static ArrayList < Element > getChildElements ( Node node ) { ArrayList < Element > childElements = new ArrayList <> ( ) ; NodeList childNodes = node . getChildNodes ( ) ; for ( int i = 0 ; i < childNodes . getLength ( ) ; i ++ ) { if ( childNodes . item ( i ) instanceof Element ) { childElements . add ( ( Element ) childNodes . item ( i ) ) ; } } return childElements ; }
Only return child nodes that are elements - text nodes are ignored .