我正在尝试从 HTML 中获取一些数据
$xdata = simplexml_import_dom($doc);
$datas = $xdata->xpath("//*[@class='proglist']");
$aData = array();
foreach($datas as $data)
{
$rightdatas = $data->xpath("*[@class='progright']");
$rt = $rightdatas[0];
print_r($rt);
$content = $rt->xpath("*[@class='progrighthead']");
print_r($content );
}
如果我打印出类的内容,$rt
那么progrighthead
该类就在那里,但$content
变量是空的。为什么?
为什么我收到以下语法的相同结果?
$xdata = simplexml_import_dom($doc);
$datas = $xdata->xpath("//*[@class='proglist']");
$aData = array();
foreach($datas as $data)
{
$rightdatas = $data->xpath("*[@class='progright']");
$rt = $rightdatas[0];
print_r($rt);
$content = $rt->xpath("*[@class='progrighthead']");
}
和
$datas = $xdata->xpath("//*[@class='progrighthead']");