Xpath gets multiple p-tags in one nodeValue

I would like to get all p tags in a div class="post" in one nodeValue. Here is my HTML:

 <div class="blogEntry expecting featured featured-post-today%e2%80%99s-top-story first"> <h2><a href="/2013/09/03/rachel-zoe-pregnant-expecting-second-child/" rel="bookmark" title="Permanent Link to Rachel Zoe Expecting Second&nbsp;Child">Rachel Zoe Expecting Second&nbsp;Child</a></h2> <div class="post"> <p>Sometext</p> <p>someothertext</p> </div> <div class="blogEntry expecting featured featured-post-today%e2%80%99s-top-story first"> <h2><a href="someurl" rel="bookmark" title="Permanent Link to Rachel Zoe Expecting Second&nbsp;Child">sometitle</a></h2> <div class="post"> <p>Sometext</p> <p>someothertext</p> </div> </div> 

Here is my xpath:

 $finder->query('//div[contains(@class,"blogEntry")]//div[@class="post"]//p'); 
+1
php xpath
Sep 03 '13 at 20:49 on
source share
2 answers

It should be:

 $finder->query('//div[contains(@class,"blogEntry")]/div[@class="post"]/p'); 
0
Sep 03 '13 at 20:53 on
source share

Very ugly, but hope this is the one you are looking for -

 //div[contains(@class,"blogEntry")]/div[@class="post"]/concat(p[1]," ",p[2]) 

or

 //div[contains(@class,"blogEntry")]/div[@class="post"]/string-join((p[1],p[2])," ") 

Exit

 Sometext someothertext Sometext someothertext 
+1
Sep 03 '13 at 21:25
source share



All Articles