1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
try {
// Tu récupère une instance de Sax
SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser sp = spf.newSAXParser();
XMLReader xr = sp.getXMLReader();
// Tu fournis ton handler (Cf. Tuto sur le parsing)
xr.setContentHandler(new TotoHandler());
// Et pour finir tu donnes l'URL
xr.parse(new InputSource("fichier.xml"));
} catch (IOException e1) {
e1.printStackTrace();
} catch (SAXException e1) {
e1.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
} |