Sunday, 25 August 2013

Exception occuring while extracting the value of the node in xdocument

Exception occuring while extracting the value of the node in xdocument

I have an xml like :
<RunResult>
<PreviewRecords>
</PreviewRecords>
<RecordsProcessed>100</RecordsProcessed>
<LogError>false</LogError>
</RunResult>
I am using the following command to fetch the value of the node
'RecordsProcessed' ,
int NofRecords = 0;
NofRecords =
Convert.ToInt32(xdRunResultDoc.Root.Element("RunResult").Element("RecordsProcessed").Value;
But at this line it is throwing exception " object reference not set to an
instance of an object".
Please suggest where I am going wrong.

No comments:

Post a Comment