Code example for XmlResourceParser

Methods: getAttributeIntValue, getAttributeValue

0
	} 
 
 
	private static TMXTileSet readTMXTileSet(XmlResourceParser xrp) throws XmlPullParserException, IOException {
		final TMXTileSet ts = new TMXTileSet();
		ts.firstgid = xrp.getAttributeIntValue(null, "firstgid", 1);
		ts.name = xrp.getAttributeValue(null, "name");
		ts.tilewidth = xrp.getAttributeIntValue(null, "tilewidth", -1);
		ts.tileheight = xrp.getAttributeIntValue(null, "tileheight", -1);
		XmlResourceParserUtils.readCurrentTagUntilEnd(xrp, new XmlResourceParserUtils.TagHandler() {
			public void handleTag(XmlResourceParser xrp, String tagName) {
				if (tagName.equals("image")) {
					ts.imageSource = xrp.getAttributeValue(null, "source");
					ts.imageName = ts.imageSource;
 
					int v = ts.imageName.lastIndexOf('/');
					if (v >= 0) ts.imageName = ts.imageName.substring(v+1);
				} 
			} 
		}); 
		return ts;