【发布时间】:2011-05-04 17:26:32
【问题描述】:
当我的内容包含下面的表格标记时出现错误。这是错误消息:
警告:DOMDocument::loadHTML() [domdocument.loadhtml]:意外的结束标记:实体中的 col,行:2
在我的代码中引用了这一行:
$dom->loadHTML(strtolower($post->post_content));
我的内容包含这个表格标记...
<table style="height: 658px;"
border="0"
cellspacing="0"
cellpadding="0"
width="472">
<colgroup>
<col width="188"></col>
<col width="590"></col>
</colgroup>
<tbody>
<tr height="20">
<td width="188" height="20"></td>
<td width="590"></td>
</tr>
</tbody>
</table>
我正在使用这个函数来解析它......
function doTheParse($heading)
{
global $post;
$content = $post->post_content;
if($content=="") return false;
$keyword = trim(strtolower(rseo_getKeyword($post)));
$dom = new DOMDocument;
$dom->loadHTML(strtolower($post->post_content));
$xPath = new DOMXPath($dom);
switch ($heading)
{
case "img-alt": return $xPath->evaluate('boolean(//img[contains(@alt, "'.$keyword.'")])');
default: return $xPath->evaluate('boolean(/html/body//'.$heading.'[contains(.,"'.$keyword.'")])');
}
}
【问题讨论】:
标签: dom error-handling html-parsing