1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
private class MySaxHandler extends DefaultHandler {
public void read (InputStream input){
SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser sp;
try {
sp = spf.newSAXParser();
XMLReader xr = sp.getXMLReader();
xr.setContentHandler( this );
xr.parse(new InputSource(input));
}
catch (ParserConfigurationException e) {
Log.e("XML", "PASCAL : ParserConfigurationException");
}
catch (SAXException e) {
Log.e("XML", "PASCAL : SAXException");
}
catch (IOException e) {
Log.e("XML", "PASCAL : IOException");
}
}
@Override
public void startDocument() throws SAXException {
Log.w("XML", "PASCAL : startDocument du XML");
}
public void startElement (
String uri, String localName,
String qName, Attributes MesAttri ) throws SAXException {
Log.w("XML", "PASCAL : startElement du XML : Debut TAG = " + localName);
}
public void characters( char ch[], int start, int length )
{
//Log.w("XML", "PASCAL : characters du XML : ch[0] = " + phrase );
}
public void endElement ( String uri, String localName, String qName)
throws SAXException {
Log.w("XML", "PASCAL : endElement du XML : Fin TAG = " + localName);
}
public void endDocument() throws SAXException {
Log.w("XML", "PASCAL : endDocument du XML");
}
} |
Partager