2
我想如果我打印出$rt
的含量比progrighthead
類從HTML如何使用xpath獲取元素?
$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 );
}
得到一些數據是存在的,但$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']");
請問您可以包含加載的文件嗎? – meiamsome 2012-07-27 13:08:06