Hello!
Ive successfully written code to parse a XML file from an internet URL. Now Im trying to do the same thing to a local file and im missing something simple (i think).
SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser sp = spf.newSAXParser();
/* Get the XMLReader of the SAXParser we created. */
XMLReader xr = sp.getXMLReader();
/* Create a new ContentHandler and apply it to the XML-Reader*/
ExampleHandler myExampleHandler = new ExampleHandler();
xr.setContentHandler(myExampleHandler);
fin = new FileReader(filename);
xr.parse(new InputSource(fin));
fin is declared as a FileReader object and initialized to null. When I parsed a file from the internet, I used the following code instead of the code in bold above:
xr.parse(new InputSource(url.openStream()));
Thanks for the help!