I have an XML data that for some of the transactions an element is missing. My goal is whenever, that element is missing I’d like to write default value that says “Data does not exist” under that column/ element. I want to write the condition that allows me to proceed to the next transaction after populating the missing element with the default value.
If (String.IsNullOrEmpty(currentItem.Descendants(xns_WD+“Race_Ethnicity__Locale_Sensitive_”).First().Value), “ Data does not exist”, currentItem.Descendants(xns_WD+“Race_Ethnicity__Locale_Sensitive_”).First().Value)
I tried to run it again using
If (String.IsNullOrEmpty(currentItem.Descendants(xns_WD+“Race_Ethnicity__Locale_Sensitive_”).First().Value), “ Data does not exist ”, currentItem.Descendants(xns_WD+“Race_Ethnicity__Locale_Sensitive_”).First().Value)
Query and it failed on the same transaction.
Just wanted to share how the missing element look like in XML
A you can see in the above, for the first portion the element does not exist and it can be found on the second one. @ppr this query
currentItem.Descendants(xns_WD+“Race_Ethnicity__Locale_Sensitive_”).Select(Function (x) x.Value).FirstOrDefault(“NOTFOUNDDEFAULTTEXT”)
did not work for me.
Looking forward to hearing from you.
Thanks a lot!