Micha
Micha

Reputation: 35

Extract div content from htmlsource in string (Java)

i'm trying to extract the content of an special div-tag(defined by his classname) out of a string that contains html source. I think the regexp-features of Java are not as easy to use as in perl, right?

Does anyone did this before and can give me a piece of code? perhaps dom-browsing is a good solution, but i didn't found any tutorials, matching to my problem.

Upvotes: 2

Views: 1661

Answers (2)

A_M
A_M

Reputation: 7851

You could use HTML Parser or some other HTML parsing library from this list.

Upvotes: 1

alphazero
alphazero

Reputation: 27244

Based on your comments it sounds like you have a general case ("crawler") and thus you're effectively parsing an XML file. If the source page is xhtml, then you have a variety of options in various XML libraries. (JDom, for example).

Upvotes: 0

Related Questions