Here you can find the source of getBooleanAttribute(Node targetElem, String keyName, boolean defaultValue)
public static boolean getBooleanAttribute(Node targetElem, String keyName, boolean 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:/* ww w .j av a 2 s .c o m*/ * Bruno Medeiros - initial API and implementation *******************************************************************************/ import org.w3c.dom.Node; public class Main { public static boolean getBooleanAttribute(Node targetElem, String keyName, boolean defaultValue) { String enabledStr = getAttribute(targetElem, keyName, null); if (enabledStr == null) { return defaultValue; } return Boolean.parseBoolean(enabledStr); } public static String getAttribute(Node targetElem, String keyName, String defaultValue) { Node attribute = targetElem.getAttributes().getNamedItem(keyName); if (attribute == null) { return defaultValue; } return attribute.getTextContent(); } }