Java XML Attribute Get getAttributeValue(final Node candidate, final String attributName)

Here you can find the source of getAttributeValue(final Node candidate, final String attributName)

Description

Returns the attribut value or null if attribut does not exist.

License

Open Source License

Declaration

static String getAttributeValue(final Node candidate, final String attributName) 

Method Source Code

//package com.java2s;
/*/*from   w w w  .jav a  2s. c o m*/
 *    Geotoolkit.org - An Open Source Java GIS Toolkit
 *    http://www.geotoolkit.org
 *
 *    (C) 2016, Geomatys
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License as published by the Free Software Foundation;
 *    version 2.1 of the License.
 *
 *    This library 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
 *    Lesser General Public License for more details.
 */

import org.w3c.dom.NamedNodeMap;

import org.w3c.dom.Node;

public class Main {
    /**
     * Returns the attribut value or null if attribut does not exist.
     */
    static String getAttributeValue(final Node candidate, final String attributName) {
        final NamedNodeMap attributs = candidate.getAttributes();
        if (attributs != null) {
            final Node attribut = attributs.getNamedItem(attributName);
            if (attribut != null) {
                return attribut.getNodeValue();
            }
        }
        return null;
    }
}

Related

  1. getAttributeValue(Element element, String tag)
  2. getAttributeValue(final Element e, final String attributeName)
  3. getAttributeValue(final Element el, final String attrName)
  4. getAttributeValue(final Element element, final String attributeName)
  5. getAttributeValue(final Element element, final String name)
  6. getAttributeValue(final Node iNode, final String iAttributeName)
  7. getAttributeValue(final Node node, final String attributeName)
  8. getAttributeValue(final Node node, final String name)
  9. getAttributeValue(final XMLStreamReader reader, final String name)