Hello, I am trying to add a new node to a xml file. The code that I wrote works fine when there is a node exists but if not it throws an error of "object referance not set to an instance of an object." Basiccaly code copies a node and then writes data to the child nodes of the parent node. When I debug this code; XmlNode credentialsnodedetails = xmlDocument.SelectNodes("/Credentials/Credential")[0]; XmlNode newnode = credentialsnodedetails.CloneNode(true); I see that "credentialsnodedetails" value is NULL. I think because it is null I am having the problem. What should do programatically to avoid it?
try{ //your code here... } catch{ //catch exception here... and do what ever you want with it. }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)