Here you can find the source of getElementArrayInt(Element root, String name, String attrib)
public static int[] getElementArrayInt(Element root, String name, String attrib)
//package com.java2s; import org.w3c.dom.*; import java.util.*; public class Main { /**/*from w w w.j ava 2 s. c om*/ * Takes a number of tags of name 'name' that are children of 'root', and * looks for attributes of 'attrib' on them. Converts attributes to an * int and returns in an array. */ public static int[] getElementArrayInt(Element root, String name, String attrib) { if (root == null) return null; NodeList nl = root.getChildNodes(); LinkedList elementCache = new LinkedList(); int size = nl.getLength(); for (int i = 0; i < size; i++) { Node node = nl.item(i); if (!(node instanceof Element)) continue; Element ele = (Element) node; if (!ele.getTagName().equals(name)) continue; String valS = ele.getAttribute(attrib); int eleVal = 0; try { eleVal = Integer.parseInt(valS); } catch (Exception e) { } elementCache.addLast(new Integer(eleVal)); } int[] retArr = new int[elementCache.size()]; Iterator it = elementCache.iterator(); int idx = 0; while (it.hasNext()) { retArr[idx++] = ((Integer) it.next()).intValue(); } return retArr; } public static int parseInt(String val) { if (val == null) return 0; int retVal = 0; try { retVal = Integer.parseInt(val); } catch (Exception e) { } return retVal; } }