0

I have a html line where there are tags inside tags, a single tag my contain multiple class. I need to extract the text with single class name(i will know only one class name which is in the tag, which may be overriding another class also)

<p class="Body1"><span class="style3"></span><span class="style1">W</span><span class="AnyClass OverRiddenClass">extract this text </span><span class="OverRiddenClass">another text to extract </span></p>

I know the class name "OverRiddenClass" which is over riding "AnyClass" class i want to extract the text "extract this text" and also "another text to extract" from the html line using Jsoup in java.

1
  • make your question more clear. what do u mean by 'single class name' ? Commented Jul 17, 2014 at 4:43

1 Answer 1

2

Maybe I am missing the point, but in my opinion you just have to write:

Document = Jsoup.connect(yourUrl).get();
Elements elements = document.select(".OverRiddenClass");
for (Element element : elements) {
  String text = element.text();
  // further processing
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.