Java XML Attribute Get getAttribute(String name, Element element)

Here you can find the source of getAttribute(String name, Element element)

Description

get Attribute

License

Open Source License

Declaration

public static String getAttribute(String name, Element element) 

Method Source Code


//package com.java2s;
/*/*from  w w w  .j a va2s .c o  m*/
 * (c) Copyright 2010 by Volker Bergmann. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, is permitted under the terms of the
 * GNU General Public License (GPL).
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * WITHOUT A WARRANTY OF ANY KIND. ALL EXPRESS OR IMPLIED CONDITIONS,
 * REPRESENTATIONS AND WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE
 * HEREBY EXCLUDED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */

import org.w3c.dom.Element;

public class Main {
    public static String getAttribute(String name, Element element) {
        return (element.hasAttribute(name) ? element.getAttribute(name) : null);
    }
}

Related

  1. getAttribute(String attribute, Node node)
  2. getAttribute(String attribute, Node node)
  3. getAttribute(String attribute, Node node)
  4. getAttribute(String key, NamedNodeMap map)
  5. getAttribute(String name, Element el)
  6. getAttribute(String name, Element firstElement, Element secondElement)
  7. getAttribute(String name, Node node)
  8. getAttributeAsBoolean(Element elem, String attribName)
  9. getAttributeAsBoolean(Element element, String attrName, boolean defValue)