我正在使用XPath来选择内容元素,我想选择2个元素,问题是我不知道如何将2个选择器组合成1个查询。
//div[@id="dle-content"]/div[@class="mcontent_inner"]/div[@class="mcontent_inner_box"]/div[@class="article"]/img[@class=""]
//div[@id="dle-content"]/div[@class="mcontent_inner"]/div[@class="mcontent_inner_box"]/div[@class="article"]/div/div[@class="quote"]
我以为我可以做到这一点;
//div[@id="dle-content"]/div[@class="mcontent_inner"]/div[@class="mcontent_inner_box"]/div[@class="article"]/img[@class=""] and //div[@id="dle-content"]/div[@class="mcontent_inner"]/div[@class="mcontent_inner_box"]/div[@class="article"]/div/div[@class="quote"]
或
//div[@id="dle-content"]/div[@class="mcontent_inner"]/div[@class="mcontent_inner_box"]/div[@class="article"]/img[@class=""] | //div[@id="dle-content"]/div[@class="mcontent_inner"]/div[@class="mcontent_inner_box"]/div[@class="article"]/div/div[@class="quote"]
但这些都不起作用。
答案 0 :(得分:0)
你忘了括号:
此:
(//div[@id="dle-content"]/div[@class="mcontent_inner"]/div[@class="mcontent_inner_box"]/div[@class="article"]/img[@class=""]|//div[@id="dle-content"]/div[@class="mcontent_inner"]/div[@class="mcontent_inner_box"]/div[@class="article"]/div/div[@class="quote"])
应该有用。