2

How get src image and text (underline) from html string ?

src and style are fixed.

<div class="field field-name-body field-type-text-with-summary field-label-hidden"><div class="field-items"><div class="field-item even"><div> src="http://and_Snorkel_Club.jpg" *style*="width: 300px; height: 225px; float: right; margin: 10px;" During spring break, the Mount Olive College SCUBA/Snorkel Club traveled to Crystal River, Florida to expand their knowledge on aquatic life and to obtain their Open Water certification.</div></div></div></div>

2
  • Are you getting this HTML from somewhere? Or is it guaranteed never to change? Commented Mar 29, 2013 at 8:39
  • I get this html from rss feed and Yes it's format not changed.src and style of text are fixed. Commented Mar 29, 2013 at 8:47

2 Answers 2

0

If you want to get specific value from HTML content you need to Parse HTML content by using Hpple. Here's the documentation with exmple. (in this documentation you will find how to get src)

In your case you use: (by using Hpple)

TFHpple *dataParser = [TFHpple hppleWithHTMLData:placesData];

NSString *XpathQueryString = @"//div[@class='field-item even']/div/";
NSArray *listOfdata= [dataParser searchWithXPathQuery: XpathQueryString];

My code will be helpful for you.

Sign up to request clarification or add additional context in comments.

Comments

0
NSString *htmlString = @"<div class="field field-name-body field-type-text-with-summary field-label-hidden"><div class="field-items"><div class="field-item even"><div> src="http://and_Snorkel_Club.jpg" *style*="width: 300px; height: 225px; float: right; margin: 10px;" During spring break, the Mount Olive College SCUBA/Snorkel Club traveled to Crystal River, Florida to expand their knowledge on aquatic life and to obtain their Open Water certification.</div></div></div></div>";

NSMutableString *imagLink = [[NSMutableString alloc] init];
NSScanner *scanner = [[NSScanner alloc] initWithString:htmlString];

[scanner scanUpToString:@"http://" intoString:nil];
[scanner scanUpToString:@""" *style" intoString:imgLink];

NSLog(@"%@", imgLink);

Similarly, you can apply this method to fetch other text of the HTML String. or Else you could use the way iPatel have shown.

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.