Java tutorial
//package com.java2s; import org.w3c.dom.Node; public class Main { public static String getAttribute(Node node, String key) { Node namedItem = node.getAttributes().getNamedItem(key); return namedItem != null ? namedItem.getNodeValue() : null; } }