Java tutorial
//package com.java2s; //License from project: Open Source License import org.w3c.dom.Node; public class Main { static String attribute(Node node, String... attributes) { String value = attributeOrNull(node, attributes); return value == null ? "" : value; } static String attributeOrNull(Node node, String... attributes) { for (int i = 0; i < attributes.length; i++) { String attribute = attributes[i]; Node attr = node.getAttributes().getNamedItem(attribute); if (attr != null) return attr.getNodeValue(); } return null; } }