how do i return more than one node on a page? here is the code i am using, but it only returns the 1st node found.
$dom = new DOMDocument;
$dom->loadHTMLFile($URL);
$xpath = new DOMXpath($dom);
$users= $xpath->query('//b[@class="xc_user"]');
echo $users->item(0)->nodeValue;
$users
is a DOMNodeList, which you can iterate over:
foreach($users as $node) {
echo $node->nodeValue;
}
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.