3

I have the following XPATH that selects elements containing certain strings ("video" or "color" or "black and white"). The issue I am having is that one of the elements that is selected contains a string "video reprints" and although it's correct, I do not want this particular element selected. I thought I could specify NOT in the XPATH as in the following...

//div/A[contains(., 'video') or contains(., 'color') or contains(., 'black and white') and (not (contains(., 'reprint')))]

Any thoughts on how I can remove any selection that contains the string "reprints" from the selections above?

4

2 回答 2

1

这是一个优先问题。只需将所有 or-ed 条件包装到括号中:

[( ... or ... or ...) and (not(...))]
于 2012-10-18T14:35:13.183 回答
0

真的只是因为你有括号的方式,所以这会起作用:

//div/A[(contains(., 'video') or contains(., 'color') or contains(., 'black and white')) and not(contains(., 'reprints'))]
于 2012-10-18T14:36:02.993 回答