get XML Attribute Node from Node by attribute name - Android XML

Android examples for XML:XML Attribute

Description

get XML Attribute Node from Node by attribute name

Demo Code

// Copyright (c) 2004-2008 IBM Corporation and others. All Rights Reserved.
//package com.java2s;
import org.w3c.dom.*;

public class Main {
    public static Node getAttributeNode(Node sNode, String attribName) {
        NamedNodeMap attrs = sNode.getAttributes();
        if (attrs != null) {
            return attrs.getNamedItem(attribName);
        }/*  w w  w  . j a va  2 s  . co m*/
        return null;
    }
}

Related Tutorials