使用Xml未将对象引用设置为对象的实例

时间:2013-04-10 11:23:29

标签: asp.net xml

我正在尝试将我的数据插入到网络服务中。

在我的网站上提交我的提交按钮。我正在检查是否有错误:

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

但现在我收到了一个错误:

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.
谁能帮助我?

1 个答案:

答案 0 :(得分:1)

xml是否包含Logic / Errors中的错误节点。

如果不存在,可能会出现对象引用