Here you can find the source of getAttribute(Node targetElem, String keyName, String defaultValue)
public static String getAttribute(Node targetElem, String keyName, String defaultValue)
//package com.java2s; /******************************************************************************* * Copyright (c) 2015 Bruno Medeiros and other Contributors. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors://from ww w . j ava 2 s.com * Bruno Medeiros - initial API and implementation *******************************************************************************/ import org.w3c.dom.Node; public class Main { public static String getAttribute(Node targetElem, String keyName, String defaultValue) { Node attribute = targetElem.getAttributes().getNamedItem(keyName); if (attribute == null) { return defaultValue; } return attribute.getTextContent(); } }