I want to parse the following html code for my iphone application
<Html>
<body>
<div class="div_1">
<div class="div_2">some code....</div>
<div class="div_3">
<div class="div_4">
<div class="div_5">
<p>First Paragraph</p>
<p>Second Paragraph</p>
<p>Third Paragraph</p>
<p>Fourth Paragraph</p>
</div>
</div>
</div>
</div>
</body>
</Html>
I am using Hpple parser for parsing this html. The xpath query that I am using is
TFHpple *xpathParser = [[TFHpple alloc] initWithHTMLData:getHTMLData];
NSArray *elementsToSearch = [xpathParser searchWithXPathQuery:@"//div[@class='div_5']/p"];
TFHppleElement *element = [elementsToSearch objectAtIndex:0];
What I intent to get is all the p tag contents inside of div class="div_5". Using the above xpath query i am only getting the first p tag contents i.e "First Paragraph". Am i doing anything wrong in my xpath?
No. The results are all in elementsToSearch
returned by -searchWithXPathQuery
.
Try to check out:
NSLog(@"%@",[elementsToSearch description]);