Java XML Attribute from Node getIntAttribute(Node n, String s)

Here you can find the source of getIntAttribute(Node n, String s)

Description

get Int Attribute

License

Open Source License

Declaration

public static int getIntAttribute(Node n, String s) 

Method Source Code


//package com.java2s;
/* ***** BEGIN LICENSE BLOCK *****
 * Copyright (C) 2010-2011, The VNREAL Project Team.
 * //from   w w  w.java2 s. co  m
 * This work has been funded by the European FP7
 * Network of Excellence "Euro-NF" (grant agreement no. 216366)
 * through the Specific Joint Developments and Experiments Project
 * "Virtual Network Resource Embedding Algorithms" (VNREAL). 
 *
 * The VNREAL Project Team consists of members from:
 * - University of Wuerzburg, Germany
 * - Universitat Politecnica de Catalunya, Spain
 * - University of Passau, Germany
 * See the file AUTHORS for details and contact information.
 * 
 * This file is part of ALEVIN (ALgorithms for Embedding VIrtual Networks).
 *
 * ALEVIN is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License Version 3 or later
 * (the "GPL"), or the GNU Lesser General Public License Version 3 or later
 * (the "LGPL") as published by the Free Software Foundation.
 *
 * ALEVIN 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
 * or the GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License and
 * GNU Lesser General Public License along with ALEVIN; see the file
 * COPYING. If not, see <http://www.gnu.org/licenses/>.
 *
 * ***** END LICENSE BLOCK ***** */

import org.w3c.dom.Node;

public class Main {
    public static int getIntAttribute(Node n, String s) {
        return Integer.parseInt(getAttribute(n, s));
    }

    public static String getAttribute(Node n, String s) {
        return n.getAttributes().getNamedItem(s).getTextContent();
    }
}

Related

  1. generateIds(Node root, String attrName)
  2. getALLAttribute(final Node iNode)
  3. getFloatAttribute(Node node, String name, float defVal)
  4. getFloatAttribute(Node node, String name, float defVal)
  5. getIntAttr(Node node, String attrName)
  6. getIntAttribute(Node node, String attr)
  7. getIntAttribute(Node node, String attributeName, int defaultValue)
  8. getIntAttribute(Node node, String name, int defVal)
  9. getIntAttributeRequired(Node node, String attributeName)