Here you can find the source of getAttribute(Node node, String attr)
Parameter | Description |
---|---|
node | - the XML node that contains the attribute. |
attr | - the name of the attribute |
public static Node getAttribute(Node node, String attr)
//package com.java2s; /*// w w w.ja va 2 s . co m * Copyright 2014 Carnegie Mellon University * * Any opinions, findings and conclusions or recommendations expressed in this * Material are those of the author(s) and do not necessarily reflect the * views of the United States Department of Defense. * NO WARRANTY. THIS CARNEGIE MELLON UNIVERSITY AND SOFTWARE ENGINEERING * INSTITUTE MATERIAL IS FURNISHED ON AN ?AS-IS? BASIS. CARNEGIE MELLON * UNIVERSITY MAKES NO WARRANTIES OF ANY KIND, EITHER EXPRESSED OR IMPLIED, * AS TO ANY MATTER INCLUDING, BUT NOT LIMITED TO, WARRANTY OF FITNESS FOR * PURPOSE OR MERCHANTABILITY, EXCLUSIVITY, OR RESULTS OBTAINED FROM USE OF * THE MATERIAL. CARNEGIE MELLON UNIVERSITY DOES NOT MAKE ANY WARRANTY OF * ANY KIND WITH RESPECT TO FREEDOM FROM PATENT, TRADEMARK, OR COPYRIGHT * INFRINGEMENT. * * This Material has been approved for public release and unlimited * distribution except as restricted below. * * This Material is provided to you under the terms and conditions of the * Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is * provided with this Content and is also available at * http://www.eclipse.org/legal/epl-v10.html. * * Carnegie Mellon is registered in the U.S. Patent and Trademark * Office by Carnegie Mellon University. * */ import org.w3c.dom.Node; public class Main { /** * Get the value of a specific attribute on an XML node * @param node - the XML node that contains the attribute. * @param attr - the name of the attribute * @return - a node containing the attribute. */ public static Node getAttribute(Node node, String attr) { return node.getAttributes().getNamedItem(attr); } }