Attribute attr = null;
if (node instanceof Element) {
Element element = (Element)node;
attr = element.getAttribute(localName, namespace);
} else if (node instanceof ProcessingInstruction) {
ProcessingInstruction pi = (ProcessingInstruction)node;
if ("target".equals(localName))
attr = new Attribute("target", pi.getTarget());
else if ("data".equals(localName))
attr = new Attribute("data", pi.getData());
else
attr = new Attribute(localName, pi.getValue(localName));
} else if (node instanceof DocType) {
DocType doctype = (DocType)node;
if ("publicId".equals(localName))
attr = new Attribute("publicId", doctype.getPublicID());
else if ("systemId".equals(localName))