Here you can find the source of getAttribute(Element parent, String localName)
public static String getAttribute(Element parent, String localName)
//package com.java2s; //License from project: Apache License import org.w3c.dom.*; import javax.xml.namespace.QName; public class Main { public static String getAttribute(Element parent, QName name) { if (parent == null) { return null; }/* ww w . j a v a2 s. c om*/ Attr attribute; if (name.getNamespaceURI() == null) { attribute = parent.getAttributeNode(name.getLocalPart()); } else { attribute = parent.getAttributeNodeNS(name.getNamespaceURI(), name.getLocalPart()); } if (attribute != null) { return attribute.getValue(); } else { return null; } } public static String getAttribute(Element parent, String localName) { if (parent == null) { return null; } Attr attribute = parent.getAttributeNode(localName); if (attribute != null) { return attribute.getValue(); } else { return null; } } }