Html parser with java

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

Answers


HTML Parser is a HTML parser for Java.

http://htmlparser.sourceforge.net/


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());

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.


Need Your Help

Force remove all horizontal spacing in Qt

qt border margin spacing qtstylesheets

Using Qt, I've set up a main dialog with a horizontal layout. This horizontal layout contains three vertical layouts. I really want all controls in these layouts to butt right up against each other...

c/c++ clang linking error on Mac OSX - webkitgtk

c++ c macos webkit gtk

I am trying to use GTK3 and WebKitGTK. I am successful at running the following code :