Question

I have a set of HTML code, here:

<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.


Now my problem is, is that this is fed from an RSS FEED article web page and there may be 1 or even 11 <p> tags within this one <div id="content_text">. How can I fetch all of the <p> in this divider and display them formatted into a UITextField?

I am currently using the XPathQuery, btw so currently my parse looks like this:

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]];
    }

So as you can see it will only parse the second line. Any help appreciated.

Thanks, SebOH.

Was it helpful?

Solution

Please use this query to find all the

elements inside given element. div[@id='content_text']

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top