【发布时间】:2014-06-04 23:29:09
【问题描述】:
我正在使用 hpple 库来解析 html 文档。该文档看起来像
<a class="title threadtitle_unread">Promo - 20 Apr 2014</a>
<a class="title"> Promo - 19 Apr 2014</a>
<a class="title unread"> Promo - 18 Apr 2014</a>
<a class="title special"> Promo - 17 Apr 2014</a>
<a class="title threadtitle_unread">Promo - 16 Apr 2014</a>
我想使用 xpath 查询检索所有这些节点。所以,我尝试做类似的事情
TFHpple *parser = [TFHpple hppleWithHTMLData:htmlData];
NSString *xpathQueryString = @"//a[@class='title']";
NSArray *tutorialsNodes = [tutorialsParser searchWithXPathQuery:xpathQueryString];
但这可以理解地只返回一个节点,即
<a class="title"> Promo - 19 Apr 2014</a>
我可以用通配符形成一个 xpath 搜索查询,让它返回所有这些节点吗?我试图将搜索查询形成为
NSString *xpathQueryString = @"//a[@class='title']";
但这没有帮助。
我可以使用 hpple 来实现吗?如果没有,我还有哪些其他选择?
谢谢
【问题讨论】:
标签: html ios xpath html-parsing hpple