I'm parsing XML using SAX for a class I'm taking at Johns Hopkins. The teacher gave us a class to extend. His class extends DefaultHandler. Here is his class:
public abstract class XMLLoaderBase extends DefaultHandler { public abstract void endElement(String uri, String localName, String qName) throws SAXException;// other stuff...}
public class JobRequestXMLLoader extends XMLLoaderBase { SimpleDateFormat sdf_; public void endElement(String uri, String localName, String qName) throws SAXException { if (qName.equals("due-date")) { date_ = sdf_.parse(text); } }}
2/24/2006 1:10:33 PM
why don't you use a try/catch block and catch the exception instead of throwing it?
2/24/2006 1:15:42 PM
?i've never really understood exceptions. i just know to add the exception to the end of the method declaration when eclipse complains about it...
2/24/2006 1:23:46 PM
sweet. i did this:
if (qName.equals("due-date")) { try { date_ = sdf_.parse(text); jobRequest_.setDueDate(date_); } catch (ParseException ex) { ex.printStackTrace(); }
2/24/2006 1:26:39 PM
no problem
2/24/2006 1:38:33 PM