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 ?
You've got a typo in your query, descendent
vs. descendant
. descendant::p[@class="4textlist"]
works fine.
You might also consider .//p[@class="4textlist"]
.
尝试这个:
//p[@class="4textList"]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.