Java org.w3c.dom.Document getting an attribule as a string from a Node (Element)

This example shows how to get a list of attribute values from all elements with a given name.
Might not fit your needs but it should give a good idea on how to do things that are similar to this (like simply get a attribute from a singe Element).

public static List<String> getAttributesByElementName(String attribute, String element, String xmlString){
	ArrayList<Integer> listToReturn = new ArrayList<Integer>();
	Document document = XmlUtils.loadXMLAsDom(xmlString);
	NodeList nodeList = document.getElementsByTagName(element);
	for (int i = 0; i < nodeList.getLength(); i++){
		String currAttribute = ( (Element)nodeList.item(i) ).getAttribute(attribute);
		if ( !currAttribute.isEmpty() ){
			listToReturn.add(currAttribute );
	return listToReturn;