Here you can find the source of getXmlNodeAttributeValue(Node NN, String AttrName)
Parameter | Description |
---|---|
NN | The xml node in question |
AttrName | The name of the attribute |
public static String getXmlNodeAttributeValue(Node NN, String AttrName)
//package com.java2s; /* /*from www. ja v a 2 s . c o m*/ * File: Util.java * * Copyright (C) 2007 Ruth Mikkelson * * This program 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. * * You should have received a copy of the GNU General Public License * along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. * * Contact : Dennis Mikkelson<mikkelsond@uwstout.edu> * MSCS Department * HH237H * Menomonie, WI. 54751 * (715)-232-2291 * * This work was supported by the National Science Foundation under grant * number DMR-0426797, and by the Intense Pulsed Neutron Source Division * of Argonne National Laboratory, Argonne, IL 60439-4845, USA. * * * Modified: * $Log$ * Revision 1.7 2007/08/16 17:46:14 rmikk * Added GPL * Fixed calculations in working with non trailing *'s in position fields of a NeXus * file * */ import org.w3c.dom.*; public class Main { /** * Returns the String value of the given attribue of an xml node * * @param NN The xml node in question * @param AttrName The name of the attribute * @return The string representation of the value or null if * it is not possible to find this value */ public static String getXmlNodeAttributeValue(Node NN, String AttrName) { if (NN == null) return null; if (AttrName == null) return null; if (AttrName.length() < 1) return null; NamedNodeMap atts = NN.getAttributes(); if (atts != null) { Node attNode = atts.getNamedItem(AttrName); if (attNode != null) return attNode.getNodeValue(); return null; } else return null; } }