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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:04:29+00:00 2026-05-27T20:04:29+00:00

I have an html string that I get from the response of a website.

  • 0

I have an html string that I get from the response of a website. Everything I do there works awesome and I have no difficulty. What I need to go is grab the only href attribute within the html. What is the best approach for getting this URL that is contained within that attribute. I am open to any external libraries if that is necessary, I just want the most efficient way possible. Thanks.

  • 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-27T20:04:30+00:00Added an answer on May 27, 2026 at 8:04 pm

    Use this API to parse the HTML code and pick the elements you want.

    ElementParser is lightweight framework to provide easy access to xml and html content. Rather than get lost in the complexities of the HTML and XML specifications, it aspires to not obscure their essential simplicity. It doesn’t do everything, it aspires to do “just enough”.

    Source: http://touchtank.wordpress.com/element-parser/


    Here is an example of how to use the ElementParser with your own example. I hope this is helpful.

    Merry Xmas! Ho-Ho-Ho

    // Here you create the parser, don't forget to #import "Element.h" and #import "ElementParser.h"
    ElementParser * parser = [[ElementParser alloc] init];
    
    // This is the HTML source code that you want to parse
    DocumentRoot* document = [parser parseHTML:@"<html><a href=\"http://google.com\">Google Link</a></html>"];
    
    // Create an array where you will put all the <a></a> elements
    NSArray* elements = [document selectElements: @"a"];
    
    // Iterate though the array, for each element pick the "href" attribute
    NSMutableArray* results = [NSMutableArray array];
    for (Element* element in elements){
        NSString* snipet = [element attribute:@"href"];
    
        // Add the result for each element to the "results" array
        [results addObject: snipet];
    }
    
    // Print the results on the screen
    NSLog(@"%@",[results componentsJoinedByString: @"\n"]);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I have a string that contains the html from a page I just
I have a string of text that contains html, and I need to extract
I have a string that is HTML encoded: '''&lt;img class=&quot;size-medium wp-image-113&quot;\ style=&quot;margin-left: 15px;&quot; title=&quot;su1&quot;\
i have string stored in python variables, and i am outputting a html that
i get some HTML it a as ajax response, and i need to get
I have a some of html strings that my application generates. Each html 'snippet'
I have a html string held in memory after transforming to my desired template
I have an HTML string representing an element: '<li>text</li>' . I'd like to append
I have a HTML string and want to replace all links to just a
I have the following: string html_string = http://www.google.com/search?sourceid=chrome&ie=UTF-8&q=pharma; string html; html = new WebClient().DownloadString(html_string);

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.