get XML Direct Attribute - Java XML

Java examples for XML:XML Attribute

Description

get XML Direct Attribute

Demo Code

/*****************************************************************************
 * Copyright (c) 2007 Jet Propulsion Laboratory,
 * California Institute of Technology.  All rights reserved
 *****************************************************************************/
//package com.java2s;

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

public class Main {
    public static Node getDirectAttribute(Node node, String name) {
        Node attribute = null;/*from  w ww  .  j  av  a2 s . com*/

        NamedNodeMap attributes = node.getAttributes();
        if (attributes != null) {
            attribute = attributes.getNamedItem(name);
        }

        return attribute;
    }
}

Related Tutorials