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>

4

2 回答 2

0

如果您想从HTML内容中获取特定价值,您需要使用Hpple解析 内容。这是带有示例的文档。(在本文档中,您将找到如何获取srcHTML

在您的情况下,您使用:(通过使用 Hpple

TFHpple *dataParser = [TFHpple hppleWithHTMLData:placesData];

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

我的代码将对您有所帮助。

于 2013-03-29T08:45:45.077 回答
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);

同样,您可以应用此方法来获取 HTML 字符串的其他文本。否则,您可以使用 iPatel 显示的方式。

于 2013-03-29T11:13:21.880 回答