so i have an attribute to a node which contains something like this:
number=”1″
i thought if i parse on = I could just use Integer.parseInt(node.getAttributes().item(i).toString()));
but this returns the following error:
java.lang.NumberFormatException: For input string: ""1""
so now i’m doing:
String[] value = node.getAttributes().item(i).toString().split("=\"");
String[] number = value[1].split("\"");
Integer.parseInt(number[0].toString()) // contains the right value 1
is there a better, cleaner way of doing this? feel like this is cheesy..
EDIT:
node is defined this way:
org.w3c.dom.Node node = nodeList.item(index);
Replace
with
http://docs.oracle.com/javase/7/docs/api/org/w3c/dom/Node.html#getNodeValue%28%29