Here you can find the source of getAttribute(Node node, String attributeName)
public static String getAttribute(Node node, String attributeName)
//package com.java2s; /*//from w w w . j av a 2 s . c o m * NodeUtil.java * * Copyright (c) 2008-2010 CSIRO, Delft University of Technology. * * This file is part of Darjeeling. * * Darjeeling is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Darjeeling 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 Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with Darjeeling. If not, see <http://www.gnu.org/licenses/>. */ import org.w3c.dom.Node; public class Main { public static String getAttribute(Node node, String attributeName) { Node attributeNode = node.getAttributes().getNamedItem(attributeName); if (attributeNode == null) return null; else return attributeNode.getNodeValue(); } }