title: Finding All Elements within a P tag using Xpath in iOS
body: <p>I don't really think the iOS part of this question really matters too much, but I just thought I would add that part just to be safe. I'm trying to parse through some HTML for an App (the client wants to parse the HTML instead of using a Web View) and I'm using the hpple code I found from another question along with the XPath format for searching. I'm pretty comfortable with Xpath, never really used it but I'm starting to understand it but I'm stuck on trying to get one part of the HTML (I'm able to search and find everything else I need). From the source HTML file what I need to pull is enclosed in a p tag, but within the p tag there could be several other nodes as well (such as a href', em, br", etc). The whole p tag that I want is also enclosed within a div class, and I've tried to see if I can pull all elements under the div class, as well as within the p but so far I can't seem to get what I need. Below is a quick sample of how the HTML would look. </p>
  
  <pre><code>&lt;div class='post'&gt;&lt;p&gt; This is some sample text that also includes a &lt;a href="www.link.com"&gt;Sample Link&lt;/a&gt; and also some &lt;em&gt;formatted&lt;/em&gt; text.&lt;p&gt;&lt;p&gt; A New line may also be present&lt;/p&gt;&lt;/div&gt;
  </code></pre>
  
  <p>So what I really need to get is all <code>&lt;p&gt;</code> tags within the div class since in some cases there could be more. I've tried <code>//div[@class='body']/p[text()]</code> in my latest attempt but that didn't work either, it just pulled a period from the post. </p>
  
  <p>Once I get everything I want to convert the entire post to a NSString that will be used in the App, but that part I can pretty much do on my one once I get the XPath search format correct. Thanks. </p>
  
  <p>EDIT: 
  Here is the code in iOS that I'm using to first perform the Xpath search and then turn the result into a string. Maybe it's in here that I'm doing something wrong. </p>
  
  <pre><code>NSArray *foundPosts = [xpathParser search:@"//div[@class='post']//p//node()"];
  TFHppleElement *postelement = [foundPosts objectAtIndex:0];
  NSString *Posts = [postelement content];
  </code></pre>