question: public static List < ? extends Node > evaluateXPath ( Document doc , String path ) throws XPathExpressionException { XPathFactory factory = XPathFactory . newInstance ( ) ; XPath xpath = factory . newXPath ( ) ; xpath . setNamespaceContext ( new NamespaceResolver ( doc ) ) ; XPathExpression expr = xpath . compile ( path ) ; NodeList nodes = ( NodeList ) expr . evaluate ( doc , XPathConstants . NODESET ) ; List < Node > nodelist = new ArrayList < Node > ( ) ; for ( int i = 0 ; i < nodes . getLength ( ) ; ++ i ) { nodelist . add ( nodes . item ( i ) ) ; } LOG . trace ( String . format ( "Evaluated XPath: %s and found %s" , path , nodeListToString ( nodelist ) ) ) ; return nodelist ; }
target:  Takes a Document and evaluates an XPath expression on it. All matching Nodes are returned as a List.