Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7158269
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:02:13+00:00 2026-05-28T13:02:13+00:00

Im using JSoup to parse HTML response. I have multiple Div tags. I have

  • 0

Im using JSoup to parse HTML response. I have multiple Div tags. I have to select Div tag based on an ID.

My pseudo code looks like this,

Document divTag = Jsoup.connect(link).get();
Elements info = divTag.select("div#navDiv");

where navDiv is the ID. But it doesnt seem to work.

Also I would want to select Href inside the Div based on some title, where hrefTitle[] would be string array. So while iterating the href I would check if the title is present in the string array, if so i would add them to list else ignore. How do i select href inside Div ? and How to select title? any inputs much appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T13:02:14+00:00Added an answer on May 28, 2026 at 1:02 pm

    But it doesnt seem to work.

    It should work. Proof:

    Document doc = Jsoup.parse("<html><body><div/>" + 
        "<div id=\"navDiv\">" + 
            "<a href=\"href1\">link1</a>" +
            "<a href=\"href2\">link2</a><" +
        "</div></body></html>");
    Element div = doc.select("div#navDiv").first();
    

    Now, we can select the a element inside the div that has (for example) an href attribute whose value is href2:

    System.out.println(div.select("a[href=href2]"));
    

    Output:

    <a href="href2">link2</a>
    

    You can find the full selector syntax here:

    • http://jsoup.org/apidocs/org/jsoup/select/Selector.html
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am using JSOUP and I have html/text something like: <html><head><style type=text/css> </style></head> <body><div
I am trying to select, using Jsoup , a <div> that has multiple classes:
I am using JSoup to parse a gb2312 charset page: http://vars.sinaapp.com/u/t/jsoup_output_encoding_issue.html source code: String
I am using a HTML parser called Jsoup, to load and parse HTML files.
I'm trying to parse online dictionary results using Jsoup, of which I have a
hi all i am using jsoup in a java-ee app to parse html i
I'm trying to parse some html using jsoup (1.3.3) in my android activity. When
I am currently using Jsoup to parse HTML document and I use the following
I'm using Java and Jsoup to parse HTML pages and I want to get
I have been using JSoup to parse lyrics and it has been great until

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.