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