Here you can find the source of getNullableAttribute(final Element node, final String attributeName)
Parameter | Description |
---|---|
node | element to retrieve the attribute value from |
attributeName | name of the targeted attribute |
public static String getNullableAttribute(final Element node, final String attributeName)
//package com.java2s; /*/*from www. jav a2s . c o m*/ Copyright (C) 2016 HermeneutiX.org This file is part of SciToS. SciToS is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. SciToS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with SciToS. If not, see <http://www.gnu.org/licenses/>. */ import org.w3c.dom.Element; public class Main { /** * Get the attribute value under the specified name from the given element. * * @param node * element to retrieve the attribute value from * @param attributeName * name of the targeted attribute * @return the attribute's value (or {@code null} if no such attribute exists) */ public static String getNullableAttribute(final Element node, final String attributeName) { if (node.hasAttribute(attributeName)) { return node.getAttribute(attributeName); } return null; } }