This is my HTML source
<li>
<a href="/info/some1>Item 1<br>
<span class="deets">111</span>
</a>
</li>
<li>
<a href="/info/some2>Item 2<br>
<span class="deets">222</span>
</a>
</li>
<li>
<a href="/info/some3>Item 3<br>
<span class="deets">333</span>
</a>
</li>
This is my Java program to get the content & it filters the HTML tags
try {
myurl = new URL("http://www.somewebsite.com");
HttpURLConnection con= (HttpURLConnection) myurl.openConnection();
InputStream result = con.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(result));
StringBuilder sb = new StringBuilder();
for(String line; (line = reader.readLine()) != null;)
//append all content & separate using line separator
sb.append(line).append(System.getProperty("line.separator"));
String final_result = sb.toString().replaceAll("\\<.*?\\>", "");
TextView tv=(TextView) findViewById(R.id.textView1);
tv.setText(final_result);
}
catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
tv.setText("not working");
}
Is there an easier way using Jsoup to parse the HTML content using Java instead of Regex
Is there a way to get only the required contents. So here I just want the contents "Item 2 - 222"
<li> <a href="/info/some2>Item 2<br> <span class="deets">222</span> </a> </li>