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']");
Here is my xml
="1.0"="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>
What I have tried:
Boolean blnPhoneFound = true;
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;
}
else if (objxmlPhoneNode != null)
{
if (objxmlPhoneNode.SelectSingleNode("Type[@Word='CELL']").InnerText == "Cell")
{
objCaseParty.Phone.Type = ConservatorService.PhoneNumberTypes.Cell;
}
}
if (objxmlPhoneNode != null)
{
if (objxmlPhoneNode.SelectSingleNode("Type").InnerText == "Work")
{
objCaseParty.Phone.Type = ConservatorService.PhoneNumberTypes.Work;
blnPhoneFound = true;
}
}
if (objxmlPhoneNode != null)
{
if (objxmlPhoneNode.SelectSingleNode("Type").InnerText == "Fax")
{
objCaseParty.Phone.Type = ConservatorService.PhoneNumberTypes.Fax;
blnPhoneFound = true;
}
}
if (blnPhoneFound)
{
if (objxmlPhoneNode.SelectSingleNode("Extension") != null)
{
string strExtension = objxmlPhoneNode.SelectSingleNode("Extension").InnerText;
objCaseParty.Phone.Extention = strExtension;
}
if (objxmlPhoneNode.SelectSingleNode("Number") != null)
{
string strNumber = objxmlPhoneNode.SelectSingleNode("Number").InnerText;
objCaseParty.Phone.Number = strNumber;
}
}
}
}
}