Java XML Attribute Get getAttribute(NamedNodeMap ruleAttributes, String attributeName)

Here you can find the source of getAttribute(NamedNodeMap ruleAttributes, String attributeName)

Description

Get an attribute by name

License

Open Source License

Parameter

Parameter Description
ruleAttributes a node map of attributes
attributeName the name of the attribute to retrieve

Return

the value of the attribute.

Declaration

public static String getAttribute(NamedNodeMap ruleAttributes, String attributeName) 

Method Source Code

//package com.java2s;
/*//from  www  .ja va 2s.  c  om
    
MiringValidator  Semantic Validator for MIRING compliant HML
Copyright (c) 2015 National Marrow Donor Program (NMDP)
    
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; either version 3 of the License, or (at
your option) any later version.
    
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
License for more details.
    
You should have received a copy of the GNU Lesser General Public License
along with this library;  if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA.
    
> http://www.gnu.org/licenses/lgpl.html
    
*/

import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;

public class Main {
    /**
     * Get an attribute by name
     *
     * @param ruleAttributes a node map of attributes
     * @param attributeName the name of the attribute to retrieve
     * @return the value of the attribute.
     */
    public static String getAttribute(NamedNodeMap ruleAttributes, String attributeName) {
        Node miringRuleNode = ruleAttributes.getNamedItem(attributeName);
        String miringRule = miringRuleNode != null ? miringRuleNode.getNodeValue() : null;
        return miringRule;
    }
}

Related

  1. getAttribute(final Node node, final String attributeName)
  2. getAttribute(final Node node, final String name)
  3. getAttribute(final Node xml, final String namespaceURI, final String localName)
  4. getAttribute(NamedNodeMap map, String name)
  5. getAttribute(NamedNodeMap namedNodeMap, String name)
  6. getAttribute(Node aNode, String attributeName)
  7. getAttribute(Node attrNode)
  8. getAttribute(Node currentNode, String attributeName)
  9. getAttribute(Node element, String attName)