File tree Expand file tree Collapse file tree 1 file changed +13
-9
lines changed
src/main/java/org/scijava/util Expand file tree Collapse file tree 1 file changed +13
-9
lines changed Original file line number Diff line number Diff line change @@ -188,15 +188,7 @@ public String cdata(final String expression) {
188188
189189 /** Obtains the elements identified by the given XPath expression. */
190190 public ArrayList <Element > elements (final String expression ) {
191- final NodeList nodes = xpath (expression );
192- final ArrayList <Element > elements = new ArrayList <Element >();
193- if (nodes != null ) {
194- for (int i =0 ; i <nodes .getLength (); i ++) {
195- final Node node = nodes .item (i );
196- if (node instanceof Element ) elements .add ((Element ) node );
197- }
198- }
199- return elements ;
191+ return elements (xpath (expression ));
200192 }
201193
202194 /** Obtains the nodes identified by the given XPath expression. */
@@ -248,6 +240,18 @@ public static String cdata(final Element el, final String child) {
248240 return cdata (children .item (0 ));
249241 }
250242
243+ /** Gets the element nodes from the given node list. */
244+ public static ArrayList <Element > elements (final NodeList nodes ) {
245+ final ArrayList <Element > elements = new ArrayList <Element >();
246+ if (nodes != null ) {
247+ for (int i =0 ; i <nodes .getLength (); i ++) {
248+ final Node node = nodes .item (i );
249+ if (node instanceof Element ) elements .add ((Element ) node );
250+ }
251+ }
252+ return elements ;
253+ }
254+
251255 // -- Helper methods --
252256
253257 /** Loads an XML document from the given file. */
You can’t perform that action at this time.
0 commit comments