public static List < Node > getSiblings ( Node parent , Node element ) { List < Node > result = new ArrayList <> ( ) ; NodeList list = parent . getChildNodes ( ) ; for ( int i = 0 ; i < list . getLength ( ) ; i ++ ) { Node el = list . item ( i ) ; if ( el . getNodeName ( ) . equals ( element . getNodeName ( ) ) ) { result . add ( el ) ; } } return result ; }
Get siblings of the same type as element from parent .