@Override
    public String readString(String name, String defVal) throws IOException {
        String attribute = null;

        // Element.getAttribute() returns an empty string if the specified attribute does not exist.
        // see https://www.w3.org/2003/01/dom2-javadoc/org/w3c/dom/Element.html#getAttribute_java.lang.String_
        // somewhat confusing since the w3c JS api equivalent returns null as one would expect.
        // https://www.w3schools.com/jsref/met_element_getattribute.asp
        if (XMLUtils.hasAttribute(importer.getFormatVersion(), currentElement, name)) {
            attribute = XMLUtils.getAttribute(importer.getFormatVersion(), currentElement, name);
        }

        if (attribute == null) {
            return defVal;
        }

        return attribute;
    }
Part of the jME XML IO system as introduced in the Google Code jmexml project.

@author Kai Rabien (hevee) - original author of the code.google.com jmexml project
@author Doug Daniels (dougnukem) - adjustments for jME 2.0 and Java 1.5
@author blaine
jme3-plugins/src/xml/java/com/jme3/export/xml/DOMInputCapsule.java