Here you can find the source of getAttributeValue(NodeList elements, String attributeName)
Parameter | Description |
---|---|
elements | a parameter |
attributeName | a parameter |
static public String getAttributeValue(NodeList elements, String attributeName)
//package com.java2s; /*/*ww w. jav a 2 s . c o m*/ * dalclient library - provides utilities to assist in using KDDart-DAL servers * Copyright (C) 2015,2016,2017 Diversity Arrays Technology * * This program 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. * * This program 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 this program. If not, see <http://www.gnu.org/licenses/>. */ import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { /** * Return the value of the named attribute from the first Node in the NodeList * or null if the NodeList is empty or the attribute is not present. * @param elements * @param attributeName * @return a String or null */ static public String getAttributeValue(NodeList elements, String attributeName) { String result = null; if (elements != null && elements.getLength() > 0) { Node item = elements.item(0); NamedNodeMap attributes = item.getAttributes(); if (attributes != null) { Node attr = attributes.getNamedItem(attributeName); if (attr != null) { result = attr.getNodeValue(); } } } return result; } }