How can we retrieve data from a website and parse it into a readable format in the Android application? This means I want to extract data from website and use it in my android application, formatted in my way. It could be any website.
You can use
jsoup to parse any kind of web page. Here you can find the jsoup library and full source code.
Here is an example: http://desicoding.blogspot.com/2011/03/how-to-parse-html-in-java-jsoup.html
To install in Eclipse:
- Right Click on project
- Add External Archives
- select the .jar file
You can parse according to tag/parent/child very comfortably
DefaultHttpClient httpClient = new DefaultHttpClient(); HttpGet httpGet = new HttpGet("http://www.someplace.com"); ResponseHandler<String> resHandler = new BasicResponseHandler(); String page = httpClient.execute(httpGet, resHandler);
This can be used to grab the whole webpage as a string of html, i.e., “
You need to declare the following ‘uses-permission’ in the
android manifest xml file… answer by @Squonk here
And also check this answer
You can do the HTML parsing but it is not at all recommended instead ask the website owners to provide web services then you can parse that information.
Use the WebView. Simple!!