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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T05:57:34+00:00 2026-06-05T05:57:34+00:00

I am trying to retrieve the image from this html data: <div class=image> <a

  • 0

I am trying to retrieve the image from this html data:

<div class="image">
 <a href="http://www.website.com/en/105/News/10217/">
   <img src="/images/cache/105x110/crop/images%7Ccms-image-000005554.gif" 
        width="105" height="110" alt="kollsge (photo: author)" />
 </a>
</div>

This is my code:

HTMLNode *bodyNode = [parser body];

NSArray *imageNodes = [bodyNode findChildTags:@"div"];

for (HTMLNode *imageNode in imageNodes) {
    if ([[imageNode getAttributeNamed:@"class"] isEqualToString:@"image"]) {
        NSLog(@"%@", [imageNode getAttributeNamed:@"img src"]);
    } 
}

Help would be much appreciated.

I solved it by this code:

 for (HTMLNode *imageNode in imageNodes) {
        if ([[imageNode getAttributeNamed:@"class"] isEqualToString:@"image"]) {
            HTMLNode *aNode = [imageNode firstChild];
            HTMLNode *imgNode = [aNode nextSibling];
            HTMLNode *imNode = [imgNode firstChild];
            NSLog(@"%@", [imNode getAttributeNamed:@"src"]);
        } 
    }
  • 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-05T05:57:36+00:00Added an answer on June 5, 2026 at 5:57 am

    You are not going through the tree correctly. You are attempting to find an attribute named img src on your div. That would look like this:

    <div class="image" img src="whatever">
    

    For one thing, that’s not valid HTML, but the more important issue is that you want to be looking at the children. The thing you are looking for is nested inside the div, not an attribute. Since your div only has one child, a quick look at the project you provided in the comments leads me to believe that the following will work:

    HTMLNode *bodyNode = [parser body];
    
    NSArray *imageNodes = [bodyNode findChildTags:@"div"];
    
    for (HTMLNode *imageNode in imageNodes) {
        if ([[imageNode getAttributeNamed:@"class"] isEqualToString:@"image"]) {
            HTMLNode *aNode = [imageNode firstChild];
            HTMLNode *imgNode = [aNode nextSibling];
            NSLog(@"%@", [imgNode getAttributeNamed:@"src"]);
        } 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to retrieve the image url in from this html page The
This the part of HTML from which I am trying to retrieve an image.
I'm trying to retrieve a variable from an extended class. This is how my
I am trying to retrieve data from an img element inside a html web
I am trying to retrieve an image from SQL Server (yes, data type is
I'm trying to download an image using this code: from urllib import urlretrieve urlretrieve('http://gdimitriou.eu/wp-content/uploads/2008/04/google-image-search.jpg',
Iam trying to retrieve data from mysql database into stylesheet.php but it is not
I am trying to retrieve an image from an Embedded resource, and displaying it
I'm trying to retrieve image file from my local server. Here is my (very
I am trying to retrieve the image from resource file and tryin to bind

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.