无法加载和解析 DOM 对象
我正在尝试加载 dom 对象并解析它以查找特定链接
这是我的代码:
$content = file_get_contents("http://www.example.com/example.php");
$dom = new DOMDocument();
$dom->loadHTML($content);
$dom->preserveWhiteSpace = false;
var_dump($dom);
我得到的是:
对象(DOMDocument)#1 (0) { }
如果我回显 $content 我会得到所有 html。
我的代码有什么问题?
I am trying to load a dom object and to parse it for finding specific links
Here is my code:
$content = file_get_contents("http://www.example.com/example.php");
$dom = new DOMDocument();
$dom->loadHTML($content);
$dom->preserveWhiteSpace = false;
var_dump($dom);
What I get is:
object(DOMDocument)#1 (0) { }
If i echo the $content I get all the html.
What is wrong in my code?
这是手册中的示例: DOMDocument
This is an example from the manual: DOMDocument