Java tutorial
//package com.java2s; import org.w3c.dom.Element; public class Main { /** * @param element * @param atrName * @return String attribute or nul if not defined or empty */ public static String getSingleNonEmptyStringAtributeFromElement(Element element, String atrName) { String atrValue = element.getAttribute(atrName); return atrValue.isEmpty() ? null : atrValue; } }