Code example for RootElement

Methods: getChildgetContentHandler

0
 
	public List<UserBean> parse(String str) {
		final List<UserBean> ulist = new ArrayList<UserBean>();
		final UserBean currentUser = new UserBean();
		 
		RootElement root = new RootElement("result");
		Element item = root.getChild("user");
		item.getChild("name").setEndTextElementListener(
				new EndTextElementListener() {
					public void end(String body) {
						currentUser.setName(body);
					} 
				}); 
		item.getChild("phone").setEndTextElementListener(
				new EndTextElementListener() {
					public void end(String body) {
						currentUser.setPhone(body);
					} 
				}); 
		item.setEndElementListener(new EndElementListener() {
			public void end() { 
				ulist.add(currentUser.copy());
			} 
		}); 
		try { 
			Xml.parse(new ByteArrayInputStream(str.getBytes()),
					Xml.Encoding.UTF_8, root.getContentHandler());
		} catch (Exception e) {
			throw new RuntimeException(e);
		} 
		return ulist;
	} 
Connect your IDE to all the code out there  Get Codota for Java