What is the difference between below two snippet, if i just have to parse the XML?
1.By using SAXParser parse
method:
SAXParserFactory sfactory = SAXParserFactory.newInstance();
SAXParser parser = sfactory.newSAXParser();
parser.parse(new File(filename), new DocHandler());
Now using XMLReader's parse
method acquired from SAXParser
SAXParserFactory sfactory = SAXParserFactory.newInstance();
SAXParser parser = sfactory.newSAXParser();
XMLReader xmlparser = parser.getXMLReader();
xmlparser.setContentHandler(new DocHandler());
xmlparser.parse(new InputSource("test1.xml"));
Despite of getting more flexibility, is there any other difference?