EDN Admin
Well-known member
I need to count the unique number of values in the DEVICE_VALUE element, which can vary from XML to XML file.
So the Count should be 2 for the following XML:
<pre class="prettyprint <!-- Version 1.6 Output XML-->
<TELEMESSAGE>
<TELEMESSAGE_CONTENT>
<MESSAGE>
<MESSAGE_INFORMATION>
<SUBJECT>Text Message from User: </SUBJECT>
<TIME_STAMP>20130123 12:37:03</TIME_STAMP>
</MESSAGE_INFORMATION>
<USER_FROM>
<CIML>
<NAML>
<LOGIN_DETAILS>
<USER_NAME>Username</USER_NAME>
<PASSWORD>abc</PASSWORD>
</LOGIN_DETAILS>
</NAML>
</CIML>
</USER_FROM>
<MESSAGE_CONTENT>
<TEXT_MESSAGE>
<MESSAGE_INDEX>0</MESSAGE_INDEX>
<TEXT>Enter Message Here...</TEXT>
</TEXT_MESSAGE>
</MESSAGE_CONTENT>
<USER_TO>
<CIML>
<DEVICE_INFORMATION>
<DEVICE_TYPE DEVICE_TYPE="SMS" />
<DEVICE_VALUE>5551212</DEVICE_VALUE>
<DEVICE_DESCRIPTION>PKType^XPKId^123PKName^Jane DoePKGrpId^456PKGrpDesc^NA</DEVICE_DESCRIPTION>
</DEVICE_INFORMATION>
</CIML>
</USER_TO>
<USER_CC>
<CIML>
<DEVICE_INFORMATION>
<DEVICE_TYPE DEVICE_TYPE="EmailAddress" />
<DEVICE_VALUE>5551212</DEVICE_VALUE>
<DEVICE_DESCRIPTION>PKType^XPKId^123PKName^Jane DoePKGrpId^456PKGrpDesc^NA</DEVICE_DESCRIPTION>
</DEVICE_INFORMATION>
</CIML>
</USER_CC>
<USER_CC>
<CIML>
<DEVICE_INFORMATION>
<DEVICE_TYPE DEVICE_TYPE="MobilePhone" />
<DEVICE_VALUE>7681</DEVICE_VALUE>
<DEVICE_DESCRIPTION>PKType^XPKId^123PKName^Jane DoePKGrpId^456PKGrpDesc^NA</DEVICE_DESCRIPTION>
</DEVICE_INFORMATION>
</CIML>
</USER_CC>
</MESSAGE>
</TELEMESSAGE_CONTENT>
<VERSION>1.6</VERSION>
</TELEMESSAGE>
<!--End of XML File.-->[/code]
I know the code is something along the line of:
<span style="color:#008000; font-size:small <span style="color:#008000; font-size:small <span style="color:#008000; font-size:small
SendToRecipientCount = xDocSendToBuild.Descendants().Select(el => el.DEVICE_VALUE).Distinct().Count();
<
John
View the full article
So the Count should be 2 for the following XML:
<pre class="prettyprint <!-- Version 1.6 Output XML-->
<TELEMESSAGE>
<TELEMESSAGE_CONTENT>
<MESSAGE>
<MESSAGE_INFORMATION>
<SUBJECT>Text Message from User: </SUBJECT>
<TIME_STAMP>20130123 12:37:03</TIME_STAMP>
</MESSAGE_INFORMATION>
<USER_FROM>
<CIML>
<NAML>
<LOGIN_DETAILS>
<USER_NAME>Username</USER_NAME>
<PASSWORD>abc</PASSWORD>
</LOGIN_DETAILS>
</NAML>
</CIML>
</USER_FROM>
<MESSAGE_CONTENT>
<TEXT_MESSAGE>
<MESSAGE_INDEX>0</MESSAGE_INDEX>
<TEXT>Enter Message Here...</TEXT>
</TEXT_MESSAGE>
</MESSAGE_CONTENT>
<USER_TO>
<CIML>
<DEVICE_INFORMATION>
<DEVICE_TYPE DEVICE_TYPE="SMS" />
<DEVICE_VALUE>5551212</DEVICE_VALUE>
<DEVICE_DESCRIPTION>PKType^XPKId^123PKName^Jane DoePKGrpId^456PKGrpDesc^NA</DEVICE_DESCRIPTION>
</DEVICE_INFORMATION>
</CIML>
</USER_TO>
<USER_CC>
<CIML>
<DEVICE_INFORMATION>
<DEVICE_TYPE DEVICE_TYPE="EmailAddress" />
<DEVICE_VALUE>5551212</DEVICE_VALUE>
<DEVICE_DESCRIPTION>PKType^XPKId^123PKName^Jane DoePKGrpId^456PKGrpDesc^NA</DEVICE_DESCRIPTION>
</DEVICE_INFORMATION>
</CIML>
</USER_CC>
<USER_CC>
<CIML>
<DEVICE_INFORMATION>
<DEVICE_TYPE DEVICE_TYPE="MobilePhone" />
<DEVICE_VALUE>7681</DEVICE_VALUE>
<DEVICE_DESCRIPTION>PKType^XPKId^123PKName^Jane DoePKGrpId^456PKGrpDesc^NA</DEVICE_DESCRIPTION>
</DEVICE_INFORMATION>
</CIML>
</USER_CC>
</MESSAGE>
</TELEMESSAGE_CONTENT>
<VERSION>1.6</VERSION>
</TELEMESSAGE>
<!--End of XML File.-->[/code]
I know the code is something along the line of:
<span style="color:#008000; font-size:small <span style="color:#008000; font-size:small <span style="color:#008000; font-size:small
SendToRecipientCount = xDocSendToBuild.Descendants().Select(el => el.DEVICE_VALUE).Distinct().Count();
<
John
View the full article