Java tutorial
//package com.java2s; import javax.xml.namespace.QName; import javax.xml.stream.events.Attribute; import javax.xml.stream.events.StartElement; public class Main { public static int getIntElement(StartElement startElement, String elementName) { int parent = 0; Attribute parentIdAttr = startElement.getAttributeByName(new QName(elementName)); if (parentIdAttr != null) { parent = Integer.parseInt(parentIdAttr.getValue()); } return parent; } }