Code example for XmlResourceParser

Methods: close

0
 
	public void execute(int resId, XmlHandler handler) throws XmlHandler.XmlHandlerException {
	    final XmlResourceParser parser = mRes.getXml(resId);
	    try { 
		    handler.setLocalSync(true);
	        handler.parseAndApply(parser, mResolver);
	    } finally { 
	        parser.close();
	    } 
	} 
 
	public void execute(Context context, String assetName, XmlHandler handler) throws XmlHandler.XmlHandlerException {
		try { 
			final InputStream input = context.getAssets().open(assetName);
			final XmlPullParser parser = ParserUtils.newPullParser(input);
		    handler.setLocalSync(true);
			handler.parseAndApply(parser, mResolver);
		} catch (XmlHandler.XmlHandlerException e) {
			throw e;
		} catch (XmlPullParserException e) {
			throw new XmlHandler.XmlHandlerException("Problem parsing local asset: " + assetName, e);