XPath组合/多个

时间:2015-07-31 08:47:16

标签: xpath

我正在使用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"]

但这些都不起作用。

1 个答案:

答案 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"])

应该有用。