2

I am trying to insert my data to a webservice.

while submitting my submit button on my website. and i am checking whether there is an error:

if (Convert.ToString(strXML) != "1")
{
     XmlDocument xmlDoc = new XmlDocument();
     xmlDoc.LoadXml(strXML.ToString());
     XmlNode node = xmlDoc.SelectSingleNode("Logic/Errors");
     err = node["Error"].InnerText;
}

But now i am getting an error :

Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the 
current web request. 
Please review the stack trace for more information about the error and where 
it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to 
an instance of an object.

can anyone help me ???

4
  • 1
    probably the node is null - debug your code , step by step... the single node is not found for some reason. Commented Apr 10, 2013 at 11:26
  • @Aristos yeah node is getting null value. how can i change that? Commented Apr 10, 2013 at 11:27
  • The selected node must exist in the xml... msdn.microsoft.com/en-us/library/h0hw012b.aspx Commented Apr 10, 2013 at 11:28
  • @Aristos so are you saying to add "Error" tag inside the xml? Commented Apr 10, 2013 at 11:34

1 Answer 1

1

Do that xml contains error node within Logic/Errors.

If not exist, the object reference may occur

Sign up to request clarification or add additional context in comments.

1 Comment

i have corrected the problem by myself. The issue was SElection of xml node i changed the name of xml node .

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.