List < Node > getSubnodes ( Node parent ) { List < Node > subs = new ArrayList <> ( ) ; NodeList nodes = parent . getChildNodes ( ) ; for ( int i = 0 ; i < nodes . getLength ( ) ; i ++ ) { Node n = nodes . item ( i ) ; if ( n . getNodeType ( ) == Node . ELEMENT_NODE ) subs . add ( n ) ; } return subs ; }
Return the subnodes of a node with non - element nodes suppressed