Code example for Element

Methods: getAttribute, hasAttribute

0
     * @param attrNameResId a resource ID referring to a string 
     * @return a string, or <code>null</code> if the attribute does not have a specified value 
     */ 
    public String findAttributeText(Element element, int attrNameResId) {
        String attrName = getString(attrNameResId);
        if (!element.hasAttribute(attrName)) return null;
        else return element.getAttribute(attrName);
    } 
 
    /** 
     * Convenience function.  Finds the text of the attribute of the name given by a resource ID 
     * and converts the time string to a number of seconds. 
     * @param element an {@link Element} 
     * @param attrNameResId a resource ID referring to a string 
     * @return a Long, or the <code>null</code> if the attribute does not have a specified value 
     * @throws XmlInvalidValueException if the attribute text cannot be interpreted as a time 
     */ 
    public Long findAttributeAsTime(Element element, int attrNameResId) throws XmlInvalidValueException {
        String text = findAttributeText(element, attrNameResId);
        if (text == null) return null;
        long seconds;