开发者

PHP DOMElement getElementsByTagName specific selector

开发者 https://www.devze.com 2023-01-07 09:47 出处:网络
$content = file_get_contents(http://www.domain.com/page.html); $dom = new DOMDocument(); if (!@$dom->loadHTML($content)) die (\"Couldn\'t load file?\");
$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");
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号