c# - Checking if child exists but still get NullReferenceException -
c# - Checking if child exists but still get NullReferenceException -
this question has reply here:
what nullreferenceexception , how prepare it? 21 answersi trying read xml document. nodes not contain kid , whenever programme runs across this, crashes follow error:
system.nullreferenceexception: object reference not set instance of object.
i checking null next way:
var test = node.selectsinglenode("ele:group", ns).innertext; if(test != null) response.write(test.tostring()); but still error above. why this?
resolved: right code:
if (node.selectsinglenode("ddf:additionalconstraint", ddfnamespace) != null)
check if node null before getting innertext.
c# asp.net xml visual-studio-2012
Comments
Post a Comment