开发者

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");
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜