PHP DOMElement getElementsByTagName specific selector
$content = file_get_contents(http://www.domain.com/page.html);
$dom = new DOMDocument();
if (!@$dom->loadHTML($content)) die ("Couldn't load file?");
$title = $dom->getElementBy开发者_如何学GoId("cssid");
$data['heading'] = $title->nodeValue; // this works fine
I would like to be able to select all p
tags that are within a certain id. With Jquery Ii would do something like $('#mycssid p');
How would I do this using the DOMDocument class
$x = new DOMXPath($dom);
$nodelist = $x->query("//*[@id='cssid']//p");
精彩评论