Java XML Attribute Get getAttributeOrNull(String attribute, Element element)

Here you can find the source of getAttributeOrNull(String attribute, Element element)

Description

get Attribute Or Null

License

Open Source License

Declaration

public static Node getAttributeOrNull(String attribute, Element element) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import org.w3c.dom.*;

public class Main {
    public static Node getAttributeOrNull(String attribute, Element element) {
        if (!element.hasAttributes()) {
            return null;
        }// w  w  w.  j  ava 2s  .  com
        NamedNodeMap attributes = element.getAttributes();
        return attributes.getNamedItem(attribute);
    }
}

Related

  1. getAttributeNS(Element el, String namespaceURI, String localPart)
  2. getAttributeNS(Element elem, String namespace, String att)
  3. getAttributeNSName(Element e, String attrName)
  4. getAttributeNSOrNull(Element e, String name, String nsURI)
  5. getAttributeNSOrNull(Element e, String name, String nsURI)
  6. getAttributePropertyFromElement(final Element element, final String attribute)
  7. getAttributes(Element el)
  8. getAttributes(Element el)
  9. getAttributes(Element el)