Is it possible to use a SAX parser inside a servlet? How do I set the DocumentHandler?

divya nagireddy

Yes it is possible to use a SAX parser inside a servlet.

URL url1 = new URL("http://host:port/yourfile.xml");
BufferedReader in = new BufferedReader( new InputStreamReader(url1.openStream()));
AppContentHandler myContentHandler = new AppContentHandler();
XMLReader parser = new SAXParser();
parser.setContentHandler (myContentHandler);
where AppContentHandler is a class which implements ContentHandler, hence implements all the parsing methods in the ContentHandler.
0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact