Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an "or" in XPath selectors?

Tags:

php

xpath

I am having the following xPath that gets image from <div class="separator">. My question is how can I make the xPath to search in <div class="entry"> also?

$img = $xpath->query('//div[@class="separator"]//img');

Thanks in advance :)

like image 540
EnexoOnoma Avatar asked Mar 29 '11 03:03

EnexoOnoma


People also ask

How do you write XPath with or?

if you are looking OR (|) operator in xpath, you can try like this "(.//span[@class='g-title'])[2]|.//span[@class='g-title']" .

Can we use comparison operators in XPath?

XPath expressions can use comparison operators. Comparison operators compare one value to another. The resulting value is a "boolean" value.

What is text () in XPath?

XPath text() function is a built-in function of the Selenium web driver that locates items based on their text. It aids in the identification of certain text elements as well as the location of those components within a set of text nodes. The elements that need to be found should be in string format.

What will be the XPath expression to select?

XPath uses path expressions to select nodes or node-sets in an XML document. The node is selected by following a path or steps.


1 Answers

$img = $xpath->query('//div[@class="separator" or @class="entry"]//img');
like image 110
alex Avatar answered Oct 15 '22 06:10

alex