Parse "div" which have no name or id , only class atrribute , with htmlClener in android

105 views Asked by At

I am trying to parse the HTML webpage which have the div elements with the only class attribute. I need to extract information from it. It is multiple div element with so i need to traverse through DOM. But I can't identify the div element.

2

There are 2 answers

2
frogatto On BEST ANSWER

Switch to Jsoup, It's really awesome!

In my opinion you should use . It is Java HTML parser. Its feature is listed below.

  • Ability to fetch web pages from network
  • Very simple and straightforward API
  • CSS selector to tagert HTML element(s).

For example you want to get a DIV elements with class foo

Document doc = Jsoup.connect("http://website.com/").get();
Elements divs = doc.select("div.foo");
0
Scott Wilson On

If you use HtmlCleaner's JDom serializer, you can then use an XPath expression to locate the div.