Java XML Attribute Get getAttribute(Node node, String name)

Here you can find the source of getAttribute(Node node, String name)

Description

Gets the attribute of the node.

License

Open Source License

Parameter

Parameter Description
node the node from which to get the attribute node
name the attribute name for which to get the node

Return

The attribute node

Declaration

public final static Node getAttribute(Node node, String name) throws DOMException 

Method Source Code

//package com.java2s;
/**//from w  w w. ja va 2s  .c om
 * Copyright (c) 1999-2007, Fiorano Software Technologies Pvt. Ltd. and affiliates.
 * Copyright (c) 2008-2015, Fiorano Software Pte. Ltd. and affiliates.
 *
 * All rights reserved.
 *
 * This software is the confidential and proprietary information
 * of Fiorano Software ("Confidential Information").  You
 * shall not disclose such Confidential Information and shall use
 * it only in accordance with the terms of the license agreement
 * enclosed with this product or entered into with Fiorano.
 */

import org.w3c.dom.*;

public class Main {
    /**
     *  Gets the attribute of the node.
     *
     *@param  node              the node from which to get the attribute node
     *@param  name              the attribute name for which to get the node
     *@return                   The attribute node
     *@exception  DOMException  if an error occurs while getting the attribute
     *      node
     */
    public final static Node getAttribute(Node node, String name) throws DOMException {
        if (node != null && node.hasAttributes()) {
            NamedNodeMap attrs = node.getAttributes();
            return attrs.getNamedItem(name);
        }
        return null;
    }
}

Related

  1. getAttribute(Node node, String attributeName)
  2. getAttribute(Node node, String attributeName, String defaultValue)
  3. getAttribute(Node node, String attrName)
  4. getAttribute(Node node, String localName, String namespaceURI)
  5. getAttribute(Node node, String localName, String namespaceURI)
  6. getAttribute(Node node, String name)
  7. getAttribute(Node node, String name)
  8. getAttribute(Node node, String name)
  9. getAttribute(Node node, String name)