0
我有這樣的代碼中的一類:DOMXPath ::查詢():無效表達
...
$document = new DOMDocument('1.0', 'utf-8');
$document->preserveWhiteSpace = false;
$content = mb_convert_encoding($content, 'HTML-ENTITIES', 'utf-8'); //this fix problems with cyrilic text
if ([email protected]$document->loadHtml($content))
return false;
$xpath = new DOMXpath($document);
$node_list = $xpath->query($this->target->query_name()); // getting warning here
...
QUERY_NAME方法的代碼(位於其他類和文件)是:
public function query_name($if_arg_needed = ""){
return "//*/*[@class=\'product_name\']";
}
兩個包含我的類的文件在utf-8中。 爲什麼我得到警告: 警告:DOMXPath ::查詢():無效的表達......
此代碼工作正常:
...
$xpath = new DOMXpath($document);
$tempStr = "//*/*[@class=\'product_name\']";
$node_list = $xpath->query($tempStr);
OMG!那些斜線!我甚至忘記了爲什麼我把它們放在那裏。非常感謝勞達! –