c# - linq to xml, handling empty tags -
the following link statement works fine if source xml contains number or if tags missing. problem have when tags empty or if non-numeric value used. can statement modified handle these situations ?
convert.toint32((string)data.elements("groupby").elements("depth").firstordefault() ?? "0")
don't know of way solve linq if cannot guarantee content of xml document easier use int.tryparse()?, e.g.
int result = 0; int.tryparse((string)data.elements("groupby").elements("depth").firstordefault(), out result);
Comments
Post a Comment