How do I check for Cell phone in if statement?

momokesh

Member
Joined
Dec 13, 2016
Messages
12
Programming Experience
1-3
Can someone please explain to me how to check the CELL phone using the same query that I used to check for the HOME phone in my if statement?
If type HOME is not found I want to get type CELL, if that is not found, I want to get type WORK, if that is not found, I want to find type FAX in that order.
I only want to get one type at a time. The phone for the type must have @Current='true'




What I need to change is the following if statement
if (objxmlPhoneNode.SelectSingleNode("Type").InnerText == 'Cell')


so that I can recheck for the CELL, WORK and FAX using,
XmlNode objxmlPhoneNode = objxmlBasePartyNode.SelectSingleNode("Phone[@Current='true' and Type/@Word='HOME']");


I am not sure how to use this in my if statement to check for CELL, WORK and FAX if there was no HOME



XmlNode objxmlPhoneNode = objxmlBasePartyNode.SelectSingleNode("Phone[@Current='true'and Type/@Word='HOME']");
if (objxmlPhoneNode != null)
{
objCaseParty.Phone = new ConservatorService.Phone();
objCaseParty.Phone.Type = ConservatorService.PhoneNumberTypes.Home;
blnPhoneFound = true;
if (objxmlPhoneNode != null)
{
if (objxmlPhoneNode.SelectSingleNode("Type").InnerText == "Cell")
{
objCaseParty.Phone.Type = ConservatorService.PhoneNumberTypes.Cell;
}
}
}

Here is my xml document

<?xml version="1.0" encoding="UTF-8"?>
<Party ID="14884325" InternalPartyID="1612739531">
<Phone Current="true">
<Type Word="FAX">Fax</Type>
<Number>999-999-9999</Number>
</Phone>
<Phone>
<Type Word="FAX">Fax</Type>
<Number>999-999-9999</Number>
</Phone>
<Phone Current="true">
<Type Word="HOME">Home</Type>
<Number>777-777-7777</Number>
</Phone>
<Phone>
<Type Word="HOME">Home</Type>
<Number>777-777-7777</Number>
</Phone>
<Phone Current="true">
<Type Word="WORK">Work</Type>
<Number>111-222-0000</Number>
</Phone>
<Phone>
<Type Word="WORK">Work</Type>
<Number>111-222-0000</Number>
</Phone>
<Phone Current="true">
<Type Word="CELL">Cell</Type>
<Number>666-666-6666</Number>
</Phone>
<Phone>
<Type Word="CELL">Cell</Type>
<Number>666-666-6666</Number>
</Phone>
</Party>
 
Last edited:
objxmlPhoneNode = objxmlBasePartyNode.SelectSingleNode("Phone[@Current='true'and Type/@Word='HOME']");
objxmlPhoneNode = objxmlBasePartyNode.SelectSingleNode("Phone[@Current='true'and Type/@Word='CELL']");

Now please ask how you can search for WORK phone ;)
 
Thanks John. I was asking how do I add what you gave me in my if statements for checking CELL, WORK and FAX? I already checked for type HOME at the beginning. I did not include all if statements I have in my code e.g. for checking for WORK and FAX. Should I include the entire if statements here?
 
Back
Top Bottom