Java tutorial
//package com.java2s; import org.w3c.dom.Node; public class Main { /** * @param sampleNode * @return The time and time unit from a sample. e.g. "day 1" or "week 2". * Returns "" if no time information is avalilable. */ public static String getSampleTimeUnit(Node sampleNode) { String timeunit; if (sampleNode.getAttributes() == null || sampleNode.getAttributes().getNamedItem("unit") == null) timeunit = null; else timeunit = sampleNode.getAttributes().getNamedItem("unit").getFirstChild().getNodeValue(); return timeunit; } }