Here you can find the source of getAttributeValueNS(Element element, String namespace, String attrName)
Parameter | Description |
---|---|
element | an Element object. |
namespace | a namespace. |
attrName | a name of an attribute |
public static String getAttributeValueNS(Element element, String namespace, String attrName)
//package com.java2s; /******************************************************************************* * Copyright (c) 2002-2005 IBM Corporation and others. * 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 2s.co m*/ * IBM - Initial API and implementation *******************************************************************************/ import org.w3c.dom.Attr; import org.w3c.dom.Element; public class Main { /** * Get attribute value. * * @param element an Element object. * @param namespace a namespace. * @param attrName a name of an attribute * @return the attribute value. */ public static String getAttributeValueNS(Element element, String namespace, String attrName) { String attrValue = null; Attr attr = null; // Get the attribute using its name if ((attr = element.getAttributeNodeNS(namespace, attrName)) != null) { attrValue = attr.getValue().trim(); } // Return attribute value return attrValue; } }