Java tutorial
//package com.java2s; import org.w3c.dom.Node; public class Main { public static String getExperimentNameFromLineNode(Node linenode) { try { Node t1 = linenode.getAttributes().getNamedItem("experimentname"); if (t1 != null) return t1.getNodeValue(); else return linenode.getOwnerDocument().getElementsByTagName("experimentname").item(0).getFirstChild() .getNodeValue(); } catch (NullPointerException npe) { return ""; } } }