Here you can find the source of getAttribute(Element element, String attr)
Parameter | Description |
---|---|
element | The element to search for a named attribute |
attr | The attribute name |
public static String getAttribute(Element element, String attr)
//package com.java2s; /***************************************************************************** * Web3d Consortium Copyright (c) 2007 - 2008 * Java Source * * This source is licensed under the GNU LGPL v2.1 * Please read http://www.gnu.org/copyleft/lgpl.html for more information * * This software comes with the standard NO WARRANTY disclaimer for any * purpose. Use it at your own risk. If there's a problem you get to fix it. * *****************************************************************************/ import org.w3c.dom.Element; public class Main { /**//w ww .j ava2s .c o m * Return the named attribute of the argument element, or * null if it does not exist. * * @param element The element to search for a named attribute * @param attr The attribute name * @return The attribute String, or null if it does not exist. */ public static String getAttribute(Element element, String attr) { String value = element.getAttribute(attr); if (value.equals("")) { value = null; } return (value); } }