Code example for Element

Methods: getChild, setStartElementListener

0
	final String NS = "";
	 
	RootElement root = new RootElement("body");
	 
	Element route = root.getChild(NS, "route");
	route.setStartElementListener(new StartElementListener() {
		public void start(Attributes atts) {
		    routeInfo.routeData.put("tag", atts.getValue("tag"));
		    routeInfo.routeData.put("title", atts.getValue("title"));
		    routeInfo.routeData.put("minLat", Double.parseDouble(atts.getValue("latMin")));
		    routeInfo.routeData.put("maxLat", Double.parseDouble(atts.getValue("latMax")));
		    routeInfo.routeData.put("minLng", Double.parseDouble(atts.getValue("lonMin")));
		    routeInfo.routeData.put("maxLng", Double.parseDouble(atts.getValue("lonMax")));
		} 
	    }); 
	 
	Element allStop = route.getChild(NS, "stop");
	allStop.setStartElementListener(new StartElementListener() {
		public void start(Attributes atts) {
		    ContentValues cv = new ContentValues();
		    String tag = atts.getValue("tag");
		    cv.put("tag", tag);
		    cv.put("title", atts.getValue("title"));
		    cv.put("lat", atts.getValue("lat"));
		    cv.put("lng", atts.getValue("lon"));
		    routeInfo.stopData.addElement(cv);
		} 
	    }); 
 
	Element direction = route.getChild(NS, "direction");
	direction.setStartElementListener(new StartElementListener() {
		public void start(Attributes atts) {
		    ContentValues cv = new ContentValues();
		    cv.put("tag", atts.getValue("tag"));
		    cv.put("title", atts.getValue("title"));
		    cv.put("route", routeInfo.routeData.getAsString("tag"));
		    routeInfo.subRouteData.addElement(cv);
 
		    // elements will be filled in by the next listener 
		    routeInfo.subRouteStops.addElement(new Vector<ContentValues>());
		} 
	    }); 
 
	 
	Element directionStop = direction.getChild(NS, "stop");
	directionStop.setStartElementListener(new StartElementListener() {
		int index;
		public void start(Attributes atts) {
		    ContentValues cv = new ContentValues();
		     
		    // Are we at the start of a new route?