EDUCBA Logo

EDUCBA

MENUMENU
  • Explore
    • EDUCBA Pro
    • PRO Bundles
    • Featured Skills
    • New & Trending
    • Fresh Entries
    • Finance
    • Data Science
    • Programming and Dev
    • Excel
    • Marketing
    • HR
    • PDP
    • VFX and Design
    • Project Management
    • Exam Prep
    • All Courses
  • Blog
  • Enterprise
  • Free Courses
  • Log in
  • Sign Up
Home Software Development Software Development Tutorials XML Tutorial XPath Multiple Conditions
 

XPath Multiple Conditions

Updated March 28, 2023

XPath Multiple Conditions

 

 

Definition of XPath Multiple Conditions

XPath multiple conditions are used to select multiple attributes, by using XPath in multiple conditions we can select any category with the attribute by specifying child node. We can define the condition in the path when we have to forward the message to more than one interface or more than one receiver. XPath multiple conditions is selecting the incoming messages while reaching the server with multiple receivers or interfaces.

Watch our Demo Courses and Videos

Valuation, Hadoop, Excel, Mobile Apps, Web Development & many more.

Overview of XPath Multiple Conditions

  • As we know that selenium is a free and open-source framework of web automation that was used to test the application across different browsers and platforms.
  • To implement the framework by using multiple conditions first we need to locate the web element.
  • In multiple conditions we can use to ways for matching the expression for one value is matching and the second value is executing.
  • We can use the call processing rule at the time of working with multiple conditions for setting the variable to skip the backside. We can also use the action of transform to send the default response back to the client by using multiple conditions.
  • We can use below syntax to use multiple conditions are as follows.

Syntax:

//quotes/category [@aattribute1 = val1 and attribute2 = val2]
//quotes/category [@aattribute1 = val1 and attribute2 = val2]
  • In above syntax quotes or category will defines as which category we are using with multiple conditions. It is very important parameter while using multiple conditions.
  • Attribute1 and attribute2 is defines the number of attributes which was we are using with multiple conditions; we can use the multiple conditions by defining the multiple attributes.
  • Value1 and value2 are defined as the value which we have defined in multiple conditions. We can use multiple values as per multiple conditions which are used in multiple conditions. XPath multiple conditions are very important and useful to define the multiple conditions.

How to use XPath multiple conditions?

  • We are using OR and AND conditions at the time of using the XPath multiple conditions are as follows.
  • The below steps show how to use XPath multiple conditions are as follows. We are creating the project name as XPathMultipleConditions. In the below step, we are creating the project template of XPath multiple conditions in spring boot.

1. At the time of creating the project we are providing project group name as com.example, artifact name as XPathMultipleConditions, project name as XPathMultipleConditions, and selected java version as 11. We are defining the version of spring boot as 2.6.7.                                

Group – com.example

Artifact name – XPathMultipleConditions

Name – XPathMultipleConditions

Spring boot – 2.6.7

Project – Maven

Java – 11

Package name – com.example. XPathMultipleConditions

Project Description – Project for XPathMultipleConditions

Dependencies – Spring web

Packaging – Jar

XPath Multiple Conditions 1-1

2. In this step, we are extracting the downloaded project and opening the same by using the spring tool suite as follows.

XPath Multiple Conditions 1-2

3. In this step, we are checking all the project structures and its files are as follows. Also, we are checking whether the pom.xml file is created or not. Suppose this file is not created then we need to create the same manually. In the below example this file is created, so we have no need to create it manually.

1-3

4. In this step we are adding dependency in multiple conditions We are adding dependency are as follows.

Code –

<dependency>
<groupId> net.sf.saxon </groupId>
<artifactId> saxon-XPath </artifactId>
<version> 8.7 </version>
</dependency>

u

5. Now we are creating student.html by defining the multiple conditions by using AND condition are as follows. In the below example also we are running the project.

Code –

<html>
</head>
<body>
<table align = "center" width = 80% cellspacing = "2" cellpadding = "2" >
<tr>
<td> Stud1 : </td>
<td> input[@type = "text" and @stud_name="ABC" and @stud_no = "1"] </td>
</tr>
<tr>
<td> Stud2 : </td>
<td> input[@type = "checkbox" and @stud_name="PQR" and class = "4th"] </td>
</tr>
<tr>
<td> Stud3 : </td>
<td> input[@type="text" and stud_name="XYZ" and stud_no = "2"] </td>
</tr>
<tr>
<td> Stud4 : </td>
<td> input [@type = "checkbox" and name = "CBD" and stud_no = "3"] </td>
</tr>
<tr>
<td> Stud5 : </td>
<td> input[@type="password" and class = "password" and stud_no = "4"] </td>
</tr>
</table>
</body>
</html>

dfr

mhj

XPath Multiple Conditions Values

  • In XPath expression single attribute will identify the multiple conditions then we can use more than one attribute in the expression of the path for locating a single element. For writing multiple conditions we can apply the AND and OR conditions.
  • In below example we are using multiple values with by using multiple OR condition are as follows.

Code –

<html>
</head>
<body>
<table align = "center" width = 90% cellspacing = "2" cellpadding = "2" >
<tr>
<td> Emp1 : </td>
<td> input[@type = "text" OR Emp_name="ABC" OR emp_no = "101"] </td>
</tr>
<tr>
<td> Emp2 : </td>
<td> input[@type = "checkbox" OR @Emp_name="PQR" OR emp_no = "102"] </td>
</tr>
<tr>
<td> Emp3 : </td>
<td> input[@type="text" OR Emp_name="XYZ" OR emp_no = "103"] </td>
</tr>
<tr>
<td> Emp4 : </td>
<td> input [@type = "checkbox" OR Emp_name = "CBD" OR emp_no = "104"] </td>
</tr>
<tr>
<td> Emp5 : </td>
<td> input[@type="password" OR emp_name = "XYA" OR emp_no = "105"] </td>
</tr>
</table>
</body>
</html>

nhj

fghj

XPath multiple conditions-xml

  • We are using multiple conditions with xml. Below is the example of multiple conditions as follows. We are creating xml file name as stud.xml as follows.
  • In below example we can see that we have used student and school tag to define the multiple conditions in xml.

Code –

<?xml version = "1.0" encoding = "utf-8"?>
<students>
<school name = "International school">
<stud> ABC <student no = "1" > Quote One </student> <student no = "2" > Quote nine </student> </stud>
</school>
<school name = "International school">
<stud> PQR
<student no = "3" > Quote two </student> </stud>
</school>
</students>

mhg

lkj

Conclusion

We can use the call processing rule at the time of working with multiple conditions for setting the variable to skip the backside. They are used to select multiple attributes, by using XPath in multiple conditions we can select any category with an attribute by specifying child node.

Recommended Articles

This is a guide to XPath Multiple Conditions. Here we discuss the Definition, How to use XPath multiple conditions, and examples with code implementation respectively. You may also have a look at the following articles to learn more –

  1. XPath Position
  2. XPath for JSON
  3. XPath regex
  4. XPath text

Primary Sidebar

Footer

Follow us!
  • EDUCBA FacebookEDUCBA TwitterEDUCBA LinkedINEDUCBA Instagram
  • EDUCBA YoutubeEDUCBA CourseraEDUCBA Udemy
APPS
EDUCBA Android AppEDUCBA iOS App
Blog
  • Blog
  • Free Tutorials
  • About us
  • Contact us
  • Log in
Courses
  • Enterprise Solutions
  • Free Courses
  • Explore Programs
  • All Courses
  • All in One Bundles
  • Sign up
Email
  • [email protected]

ISO 10004:2018 & ISO 9001:2015 Certified

© 2025 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA
Free Software Development Course

Web development, programming languages, Software testing & others

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you

EDUCBA Login

Forgot Password?

🚀 Limited Time Offer! - 🎁 ENROLL NOW