protected List < Element > filterDescendants ( Element parent , String [ ] tagNames ) { List < Element > result = new ArrayList < Element > ( ) ; for ( String tagName : tagNames ) { NodeList nodes = parent . getElementsByTagName ( tagName ) ; for ( int i = 0 ; i < nodes . getLength ( ) ; i ++ ) { Element element = ( Element ) nodes . item ( i ) ; result . add ( element ) ; } } return result ; }
Utility method for filtering an element s descendants by their tag names .