Hi My Code Masters,
Trust you all are doing just fine.
Please I want to get the Values of this Element ART from my XML files if the vale is ART i will then count Regimen else i will not. so i use this code
- int RegimenCounter = 0;
- string result = "";
- if(!string.IsNullOrEmpty(result=xd.Descendants("PrescribedRegimenTypeCode").Single().Value))
- {
- if (result == "ART")
- {
- RegimenCounter = xd.Descendants("Regimen").Count();
- }
- }
when i execute the code i am getting an exception error "Sequence Contain no Element". it because the first XML file does not contain that Element "PrescribedRegimenTypeCode" while other files have in them.
please i need your help to resolve this challenge.
thank you


Nitin SontakkeRank #264 · 9.6K reputationPosted Nov 24, 2016, 12:54 AM EST
Abraham OlatubosunRank #2,749 · 510 reputationPosted Nov 24, 2016, 1:15 AM EST
Nitin SontakkeRank #264 · 9.6K reputationPosted Nov 24, 2016, 5:49 AM EST
Manas MohapatraRank #182 · 13.2K reputationPosted Nov 24, 2016, 8:59 AM EST
Abraham OlatubosunRank #2,749 · 510 reputationPosted Nov 24, 2016, 10:32 AM EST
Object reference not set to an instance of an object
what do i do in issue like this, i suggest i will need to check first if that Element is present but how can i do that please i need any help as 9 am of 25th of Nov 2016 is my deadline