-6

I have a simple question: Let's supose i have the next span:

<span class="data" id="random">
Here the piece of string i need
</span>

How can i get what's inside of the span?

Thx! :D

ThisIsErico
  • 1,885
  • 2
  • 19
  • 24

3 Answers3

1

HTML Parser is a HTML parser for Java.

http://htmlparser.sourceforge.net/

cytinus
  • 5,467
  • 8
  • 36
  • 47
  • Yep, HTML Parser would do. But i don't want a whole project to work with; I just need a simple script that works fine... – ThisIsErico May 18 '12 at 07:28
1

Try this: JSoup, is an HTML parser for Java.

Document doc = Jsoup.connect("LINK_TO_YOUR_PAGE").get();
Elements random = doc.select("#random");
System.out.println(random.html());
Gengi
  • 633
  • 5
  • 8
-1

If you just want to use core classes rather than an HTML parser, you could use a regular expression to capture the contents of the span.

The "related" section for this question shows a lot of people asking similar parsing questions.

Community
  • 1
  • 1
chooban
  • 9,018
  • 2
  • 20
  • 36