Click here to Skip to main content
15,889,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In the xml document below, I would like to check for 3 things

1. If Phone/@Current ='true'
2. If Type/@Word ='HOME'
3. If Invalid is not true

I have done 1 and 2 but I am not sure how to do 3 in the same line of code.

My xml document which is put into an object objxmlPhoneNode

XML
<?xml version="1.0" encoding="UTF-8"?>
<Phone Op="A" Current="true">
	<Type Op="A" Word="HOME">Home</Type>
	<Number Op="A">444-081-7031</Number>
	<Invalid>true</Invalid>
</Phone>


What I have tried:

I have taken care of condition number 1 and 2. I need hep to add condition 3. i.e. If Invalid is not true.

VB
objxmlPhoneNode = objXmlPartyNode.SelectSingleNode("Phone[@Current='true' and Type/@Word='HOME']")
Posted
Comments
CHill60 29-Nov-18 5:19am    
What happens if you try the following?
objxmlPhoneNode = objXmlPartyNode.SelectSingleNode("Phone[@Current='true' and Type/@Word='HOME' and Invalid='true']")
Richard Deeming 29-Nov-18 7:29am    
Surely that should be:
... and Invalid!='true'
CHill60 29-Nov-18 7:54am    
D'oh - yes it should be!
Member 11403304 29-Nov-18 10:11am    
This is how I did it /Phone[@Current='true' and Type/@Word='HOME' and not(Invalid='true')]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900