简单的PHP Dom解析器,查找带有符号的HTML ID


Simple PHP Dom Parser to find HTML ID with symbols

我有一个问题,PHP简单的HTML dom解析器。我发现一个带有®符号的html ID,但API不识别(该类存在于html文件中)。

?>
header('Content-Type: text/html; charset=UTF-8');
require 'simple_html_dom.php';
$html = file_get_html('http://ark.intel.com/products/88194/Intel-Core-i7-6500U-Processor-4M-Cache-up-to-3_10-GHz');
//There is the problem on the ® symbol.
foreach($html->find('div#infosectionintel®platformprotectiontechnology-scrollpane') as $protection) {
$item8['osguardxx']     = $protection->find('tr#OSGuardTechVersion td.rc', 0)->plaintext;
$item8['txtxxxxxx']     = $protection->find('tr#TXT td.rc', 0)->plaintext;
$item8['exedisbit']     = $protection->find('tr#ExecuteDisable td.rc', 0)->plaintext;
$protections[] = $item8;
}
print_r($protections);
?>

我用其他没有符号的div#测试过,效果很好!!谢谢你的帮助!

您可以使用chr($ascii)(将ascii替换为ascii码®)或使用通配符,如:

foreach($html->find('div[id*=infosectionintel]', 0) as $protection) {

它会查找名字中包含 infosectionintel 的div id