說這是HTML?如何使用DOMDocument獲取標籤內容?
<html>
<body>
<embed scr="...." attr="..."></embed>
</body>
</html>
我想匹配整個嵌入標籤<embed scr="...." attr="..."></embed>
。我該怎麼做?
我能走到今天
$fragment = new DOMDocument();
$fragment->loadHTML($string);
$xp = new DOMXPath($fragment);
$result = $xp->query("//embed");
print_r($result->item(0));
您不能轉儲DOMElement或任何其他DOM對象。將節點傳遞給saveXML或saveHTML以獲取outerHTML。 – Gordon
可能重複[PHP + DOMDocument:元素的outerHTML?](http://stackoverflow.com/questions/5404941/php-domdocument-outerhtml-for-element) – Gordon