Java examples for XML:DOM Element
get Int Element from StartElement in StAX parser
//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));//w w w.ja v a 2 s . co m if (parentIdAttr != null) { parent = Integer.parseInt(parentIdAttr.getValue()); } return parent; } }