且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用PHP preg_match_all,获得href的价值

更新时间:2022-04-06 17:11:33

使用simplexml

using simplexml

$html = '<link type="text/html" rel="alternate" href="http://link"/>';
$xml  = simplexml_load_string($html);
$attr = $xml->attributes();

使用dom

$dom = new DOMDocument;
$dom->loadHTML($html);
$nodes = $dom->getElementsByTagName('link');
$attr  = $nodes->item(0)->getAttribute('href');