XPath And, OR Operator: Enhance your skills by practicing XPath And, OR Operator syntax with our given sample HTML codes and interactive exercises, designed to help you master selecting elements in HTML and XML documents.

Boost Your Skills: Practice XPath And, OR Operator Syntax with easy Exercises.


Home->Practice 6

  Next Exercise >>
Please Follow Step 1: Read XPath Question >>Step 2: Check HTML Source Code >>Step3: Enter XPath Syntax in O/P Box
XPath Exercise 6

Q1. Find header1 with And Operator

Q2. Find header2 with And Operator

Q3. Find header3 with And Operator

Q4. Find header4 with And Operator

Q5. Find header1 with OR Operator

Q6. Find header2 with OR Operator

Q7. Find header3 with OR Operator

Q8. Find header4 with OR Operator

Q9. Find Email with And Operator

Q10. Find Email with OR Operator

Q11. Find Name with And Operator

Q12. Find Name with OR Operator

HTML Source document
         <h1 id="h1" name="header1">Heading 1 </h1>
         <h2 id="h2" name="header2">Heading 2 </h2>
         <h3 id="h3" name="header3">Heading 3 </h3>
         <h4 id="h4" name="header4">Heading 4 </h4>
         
<label class="form-label" id="userEmail-label" name="Email">
Email
</label>

<p class="form-para" id="userEmail-para" name="Email">
Name
</p>
        

XPath O/P Box

Enter XPath Syntax here:   

XPath Tips and Syntax For This Page Exercise :

Using AND

//HTMLtag[@attribute_name1='attribute_value1' and @attribute_name2='attribute_value2]
    
or

//*[@attribute_name1='attribute_value1' and @attribute_name2='attribute_value2]

e.g

//input[@id='Email' and @name='password']

The and operator in XPath is used to combine two or more conditions. The and operator returns true only if all of the conditions it combines are true.

Using OR

//HTMLtag[@attribute_name1='attribute_value1' or @attribute_name2='attribute_value2]

or

//*[@attribute_name1='attribute_value1' or @attribute_name2='attribute_value2]

e.g
//input[@id='Email' or @name='password']
We would love to hear your thoughts, suggestions, concerns or problems with anything so we can improve. Request you to please use Social Media button in Right Side for this website growth.