Without your code it's impossible to say exactly where the error is.
However, when you use a reference type, you should check that it is not a null reference. That essentially means everywhere you use a period (as in "someVariable.DoSomething()"), you should have verified that the variable is not null:
So, this code is dangerous:
SomeType someVariable = xmlElement.Nodes[0];
someVariable.DoSomething();
because someVariable may be null.
To fix this, you need to check if it is safe to use it, like this:
SomeType someVariable = xmlElement.Nodes[0];
if (someVariable != null)
someVariable.DoSomething();
So look through your code, and look at all the places where you use a reference without checking if it is null.