c# - Exception occuring while extracting the value of the node in xdocument -


i have xml :

<runresult>   <previewrecords></previewrecords>   <recordsprocessed>100</recordsprocessed>   <logerror>false</logerror> </runresult> 

i using following command fetch value of node recordsprocessed ,

int nofrecords = 0; nofrecords = convert.toint32(xdrunresultdoc.root.element("runresult").element("recordsprocessed").value; 

but @ line throwing exception " object reference not set instance of object".

please suggest going wrong.

xdrunresultdoc.root points <runrdesult> element, don't have call element("runresult") again.

and suggest using (int) casting on xelement instead of convert.toint32: xelement explicit conversion (xelement int32)

int nofrecords = (int)xdrunresultdoc.root.element("recordsprocessed"); 

Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -