Reputation: 20223
I have the element $paragraph in my DOMDocument:
<p class=4textlist>
String 1
<p class=4textlist> String 1.1</p>
<p class=4textlist>String 1.2</p>
String 2
</p>
At one moment, I selected the element and I would like to get all the p tags from this elements that have the class "4textlist".
For that, I have try:
$result = $xpath->query('descendent::p[@class="4textlist"]', $paragraph);
But this is not working. Any idea please ?
Upvotes: 0
Views: 262
Reputation: 38682
You've got a typo in your query, descendent
vs. descendant
. descendant::p[@class="4textlist"]
works fine.
You might also consider .//p[@class="4textlist"]
.
Upvotes: 2