php - Xpath getting multiple p tags in one nodeValue
Get the solution ↓↓↓I'd like to retrieve all of the p tags withindiv 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 Child">Rachel Zoe Expecting Second 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 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');
Answer
Solution:
Very ugly but hope it 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])," ")
output
Sometext someothertext
Sometext someothertext
Answer
Solution:
It should be :
$finder->query('//div[contains(@class,"blogEntry")]/div[@class="post"]/p');
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: cannot set properties of undefined (setting '_dt_cellindex')
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.