By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,594 Members | 2,059 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,594 IT Pros & Developers. It's quick & easy.

How to write XPATH with conditions,

P: 14
<?xml version="1.0" encoding="utf-8"?>
<CategoryList>
<Category ID="01" Title="One">
</Category>
<Category ID="03" Title="Three">
</Category>
<Category ID="04" Title="Four">
<Style Color="Red" >
<Car Name="R"/>
</Style>
<Style Color="Blue" >
<Car Name="B"/>
</Style>
<Style Color="White" >
<Car Name="W"/>
</Style>
</Category>
<Category ID="02" Title="Two">
</Category>
</CategoryList>


"/CategoryList/Category[@ID=01]/Title"
Present im using this xpath to find "Title" value where ID=01

1? Suppose ID=01 is not( i mean 01 is not a value for ID in Xml file) available , then wt will happen and how to handle that.

and i want write Xpath ( which includes more than 2 r 3 conditions) based on conditions

2? suppose ID=4 and Color=Blue then i have find value for "Car" ( two conditions)then how to write XPATH for this
* hre we hav different values for both ID & Color,

Thanks,
Ajay
Dec 14 '07 #1
Share this Question
Share on Google+
1 Reply


Dököll
Expert 100+
P: 2,364
<?xml version="1.0" encoding="utf-8"?>
<CategoryList>
<Category ID="01" Title="One">
</Category>
<Category ID="03" Title="Three">
</Category>
<Category ID="04" Title="Four">
<Style Color="Red" >
<Car Name="R"/>
</Style>
<Style Color="Blue" >
<Car Name="B"/>
</Style>
<Style Color="White" >
<Car Name="W"/>
</Style>
</Category>
<Category ID="02" Title="Two">
</Category>
</CategoryList>


"/CategoryList/Category[@ID=01]/Title"
Present im using this xpath to find "Title" value where ID=01

1? Suppose ID=01 is not( i mean 01 is not a value for ID in Xml file) available , then wt will happen and how to handle that.

and i want write Xpath ( which includes more than 2 r 3 conditions) based on conditions

2? suppose ID=4 and Color=Blue then i have find value for "Car" ( two conditions)then how to write XPATH for this
* hre we hav different values for both ID & Color,

Thanks,
Ajay
Are you trying to do this using VB 6.0?
Dec 16 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.