2017-08-09 22 views
0

我試圖在XPath中使用OR運算符,它適用於Chrome Inspect。但它使它無法在PHP上工作。沒有OR運算符的初始XPath在PHP中工作得很好。XPath在Chrome Inspect中運行,但不在PHP中

這是初始的XPath:

//h4[text()="Description"]/following-sibling::*[not(@class)][not(@style)] 

這是改性的XPath

//h4[text()="Description"]/following-sibling::*[not(@class)|@class="MsoNormal"][not(@style)] 

我用了這個鏈接

http://websiteproperties.com/websites/13425-trademarked-brand-mens-personal-care-product-amazon-fba/

改性的XPath後,我從PHP腳本中得到這個錯誤:

Warning: DOMXPath::query(): Invalid type in D:\xampp\htdocs\PHP projects\Centurica\centurica\lib\custom\class_ff_parser.php on line 660 

Warning: DOMXPath::query(): Invalid expression in D:\xampp\htdocs\PHP projects\Centurica\centurica\lib\custom\class_ff_parser.php on line 660 
+0

請提供一個可用於重現問題的XML和您的代碼的小例子。 – ThW

回答

0

我打算髮表評論,但是我的名聲太低了。

而不是使用「|」作爲您的OR運算符,可能使用「or」一詞。這可能是你的PHP腳本可能無法解析「|」字符。

所以:

//h4[text()="Description"]/following-sibling::*[not(@class) or @class="MsoNormal"][not(@style)] 

這將是非常有益的,如果我們可以看到這是造成您的問題行代碼。

相關問題