Saturday, August 13, 2011

[android-developers] Please, Can someone give me code examples that work with html code readed on Java?

I know how to read the html code of a website, for example, the next
java code reads all the html code from
http://www.transfermarkt.co.uk/en/fc-barcelona/startseite/verein_131.html
this is a website that shows all the football players of F.C.
Barcelona.

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;

public class ReadWebPage {
public static void main(String[] args) throws IOException {
String urltext = "http://www.transfermarkt.co.uk/en/fc-barcelona/
startseite/verein_131.html
";
URL url = new URL(urltext);
BufferedReader in = new BufferedReader(new InputStreamReader(url
.openStream()));
String inputLine;

while ((inputLine = in.readLine()) != null) {
// Process each line.
System.out.println(inputLine);
}
in.close();
}
}

OK, but now i need to work with the HTML code, i need to obtain the
names ("Valdés, Victor", "Pinto, José Manuel", etc...) and the
positions (Goalkeeper, Defence, Midfield, Striker) of each of the
players of the team. For example, i need to create a `ArrayList
<String> PlayerNames` and a `ArrayList <String> PlayerPositions` and
put on these arrays all the names and positions of all the players.

How i can do it??? i can't find the code example that can do it on
google..... code examples are welcome!

thanks

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment