【发布时间】:2011-06-20 21:07:30
【问题描述】:
$p = new DOMDocument();
echo $data;
$static = $p->loadHTML($data);
$static = $static->getElementByTagName("html")->item(0);
$static = $static->getElementByTagName("body")->item(0);
$static = $static->getElementByTagName("table")->item(0);
$static = $static->getElementByTagName("tr")->item(0);
$static = $static->getElementByTagName("td")->item(0);
$static = $static->getElementByTagName("table")->item(0);
$static = $static->getElementByTagName("tr")->item(5);
$static = $static->getElementByTagName("td")->item(1);
$static = $static->getElementByTagName("div")->item(0);
$static = $static->getElementByTagName("table")->item(0);
$static = $static->getElementByTagName("tr")->item(0);
$static = $static->getElementByTagName("td")->item(0);
$static = $static->etElementByTagName("center")->item(0);
echo $static;
这就是我上面的代码,我不确定我是否做得正确,但它似乎是正确的(我试图基本上通过结构来找到我需要的确切部分)。但是我不断收到此错误:
致命错误:在第 18 行的 blah 中调用非对象上的成员函数 getElementByTagName()
(第 18 行是第一个“getElementByTagName”)
如果与此有关,我也会收到这些错误:
警告:DOMDocument::loadHTML() [domdocument.loadhtml]:打开和 结束标签不匹配:td 和 center in 实体,行:83 英寸 第 17 行
警告:DOMDocument::loadHTML() [domdocument.loadhtml]:打开和 结束标签不匹配:td 和 center in 实体,行:83 英寸 第 17 行
警告:DOMDocument::loadHTML() [domdocument.loadhtml]:打开和 结束标签不匹配:td 和 center in 实体,行:87 英寸 第 17 行
警告:DOMDocument::loadHTML() [domdocument.loadhtml]:意外结束 标记:实体中的 div,行:91 中 第 17 行
但是是的,有人可以帮忙吗?
【问题讨论】: