html - 将多行 HTML 解析加载到一个 UITextField 中

标签 html ios ios7 rss xpathquery

我有一组HTML代码,在这里:

<div id="content_text">
<p>Year 11 students will be making their course selections online this year.
</p>
<p>Information about this system has been made available through Tutor sessions. Each student will have an individual password. Once subject selections have been made students are to print out a copy of their choices and then have this form signed by themselves, their parent and their Tutor. Forms are to be completed by 22 August. Course books can be borrowed from the Library or are available online.


现在我的问题是,这是从 RSS FEED 文章网页提供的,可能有 1 甚至 11 个 <p>这里面的标签 <div id="content_text"> .我怎样才能获取所有 <p>在此分隔线中并将它们显示为 UITextField 格式?

我目前正在使用 XPathQuery , 顺便说一句,所以目前我的解析看起来像这样:

NSData *tutorialsHtmlDataTwo = [NSData dataWithContentsOfURL:[NSURL URLWithString:_storyLink]];
    TFHpple *tutorialsParserTwo = [TFHpple hppleWithHTMLData:tutorialsHtmlDataTwo];
    NSString *tutorialsXpathQueryStringTwo = @"//div[@id='content_text']/p";
    NSArray *tutorialsNodesTwo = [tutorialsParserTwo searchWithXPathQuery:tutorialsXpathQueryStringTwo];
    NSMutableArray *newTutorialsTwo = [[NSMutableArray alloc] initWithCapacity:0];
    for (TFHppleElement *element in tutorialsNodesTwo) {
        Tutorial *tutorialTwo = [[Tutorial alloc] init];
        [newTutorialsTwo addObject:tutorialTwo];
        tutorialTwo.title = [[element firstChild] content];
        _rssBody.text = [NSString stringWithFormat:@"%@", [[element firstChild] content]];
    }

如您所见,它只会解析第二行。任何帮助表示赞赏。

谢谢,SebOH。

最佳答案

请使用此查询查找给定元素内的所有

元素。 div[@id='content_text']

关于html - 将多行 HTML 解析加载到一个 UITextField 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21574479/

相关文章:

ios - 如何在 iOS 7 和 iOS 6 中支持不同的标签栏图标大小?

jquery - 在表格单元格中显示加载器

javascript - 使用 javascript/jQuery 刷新特定 div 内容

html - 垂直对齐 float Div 中的文本

objective-c - 发布 ipa : how to symbolicate my classes' calls in a stack trace? 显示框架调用

iOS8 View 很好,但在 iOS7 上较小

objective-c - 隐藏标签栏项目但仍显示 Controller

javascript - 将 span 元素向右移动到 div 标签

ios - swift 4错误的json数组解析

ios - 为什么在 iOS7 上触摸 UISearchBar 时,我的 UISearchBar 和 UITableView Cell Header 之间会出现间隙?