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 8702527
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:40:32+00:00 2026-06-13T02:40:32+00:00

I made a get request and store the response in a String response :

  • 0

I made a get request and store the response in a String response:

HttpClient client = new DefaultHttpClient(); 
String getURL = "some_url_with_param_values";
HttpGet get = new HttpGet(getURL);
HttpResponse responseGet = client.execute(get);  
HttpEntity resEntityGet = responseGet.getEntity();   
String response = EntityUtils.toString(resEntityGet);

But I am only interested in the <div>s that has the class name <div class="product-data">. So, I did this:

DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder;
InputSource is;
builder = factory.newDocumentBuilder();
is = new InputSource(new StringReader(xml));
Document doc = builder.parse(is);
NodeList list = doc.getElementsByTagName("product-data"); //I even tried: (div class="product-data)
String test = list.item(0).getNodeValue(); //Just to test it

Unfortunately, it didn’t work. Any help will be appreciated.


My response string is basically an html page.

<!DOCTYPE html .....
<html>
<head>
    //some script tags
</head>
<body>
    //some tags
    <div class="product-data">
        //some other tags
    </div>
    //some tags
    <div class="product-data">
        //some other tags
    </div>
    ....
</body>  
</html>                 
  • 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-06-13T02:40:33+00:00Added an answer on June 13, 2026 at 2:40 am

    I think you should try using getElementsByClassName('product-data')

    If that doesn’t work you could always check Jsoup, it provides an library which gives an easy way of extracting Html elements from a webpage

    DefaultHttpClient client = new DefaultHttpClient();
    HttpGet get = new HttpGet(url.toURI());
    HttpResponse resp = client.execute(get);
    
    String content = EntityUtils.toString(resp.getEntity());
    Document doc = Jsoup.parse(content);
    Elements ele = doc.select("div.classname");
    

    This example executes an Http GET and then extracts all Div elements with the class “classname” which you can then do what you like with

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I get a response from an ajax request and store request.responseText in a variable
A simple get request made to url on my server which returns HTML of
I made server/ client application in WCF. How get count of connected clients? And
I wants to read all the requests and responses made and get by the
How do I get a bugfix I made on the default branch into a
I am trying to get a web app made on Zend Framework up but
I made some ajax sites in the past where I used ajax to get
i made a webpage which use FormsAuthentication. now i need to get the user
I made a Text Field with interface builder. How can I get its text
I made a header image, but for some reason I can't get it to

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.