I'm gettin开发者_运维知识库g an error when my content contains the table markup below. Here is the error message:
Warning: DOMDocument::loadHTML() [domdocument.loadhtml]: Unexpected end tag : col in Entity, line: 2
Which is referencing this line in my code:
$dom->loadHTML(strtolower($post->post_content));
My content contains this table markup...
<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>
And I'm using this function to parse it...
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.'")])');
}
}
I'm just guessing, but since your col elements have no inner value, try using no end tag instead. So, instead of <col width="188"></col> use <col width="188" />
精彩评论