Java XML Attribute from Node getALLAttribute(final Node iNode)

Here you can find the source of getALLAttribute(final Node iNode)

Description

get ALL Attribute

License

Open Source License

Declaration

public static Vector<Attr> getALLAttribute(final Node iNode) 

Method Source Code


//package com.java2s;
/*//  w  w  w  . ja va  2s.c o m
 * Copyright (c) [yyyy] [TITULAR]
 * This file is part of [SSSSS].  
 * 
 * [SSSS] is free software; you can redistribute it and/or modify 
 * it under the terms of the GNU General Public License as published by 
 * the Free Software Foundation; either version 2 of the License, or 
 * (at your option) any later version.
 * 
 * This program 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 
 * General Public License for more details, currently published 
 * at http://www.gnu.org/copyleft/gpl.html or in the gpl.txt in 
 * the root folder of this distribution.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  
 * 02110-1301, USA.  
 */

import java.util.*;
import org.w3c.dom.*;

public class Main {

    public static Vector<Attr> getALLAttribute(final Node iNode) {
        Vector<Attr> result = new Vector<Attr>();

        // Determine if the node is null
        if (iNode != null) {
            // If the node is not null, then get the list of attributes from
            // the node
            NamedNodeMap attrList = iNode.getAttributes();

            int numAttr = attrList.getLength();

            Attr currentAttrNode = null;
            //String currentNodeName = null;

            // Loop through the attributes and get their values assuming
            // that the multiplicity of each attribute is 1 and only 1.
            for (int k = 0; k < numAttr; k++) {
                // Get the attribute
                currentAttrNode = (Attr) attrList.item(k);

                // Get the local name of the attribute
                //currentNodeName = currentAttrNode.getLocalName();

                result.add(currentAttrNode);

            } // end for loop
        }
        return result;
    }
}

Related

  1. generateIds(Node root, String attrName)
  2. getFloatAttribute(Node node, String name, float defVal)
  3. getFloatAttribute(Node node, String name, float defVal)
  4. getIntAttr(Node node, String attrName)
  5. getIntAttribute(Node n, String s)