c# - Issue Parsing XML Documnet with Linq.Xml -
this not question nullreferenceexception. question why statement shown throwing 1 , wrong it.
i attempting parse small xml document using linq.xml , getting null reference exception when attempting create list of objects linq query
_columndefs = (from def in filedef.descendants("columndef") select new columndef () { name = def.attribute("name").value, type = def.attribute("type").value, required = bool.parse(def.attribute("required").value), default = def.attribute("default").value }).tolist<columndef>();
the code here fails nullreferenceexception seen here
i'm having trouble trying figure out if new columdef object issue or else. if new columndef why "new" operator not creating instance of object?
_columndefs defined _columndefs = new list<columndef>();
your debugger view shows current item has no default
attribute. can use default = (string)def.attribute("default")
have property set null
if attribute not exist.
Comments
Post a Comment