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 answers

i 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

Popular posts from this blog

javascript - mongodb won't find my schema method in nested container -

Hibernate criteria by a list of natural ids -

ios - Lagging ScrollView with UIWebview inside -