xml 错误:在 SelectSingleNode 之后未将对象引用设置为对象的实例

l--*_*''' 3 .net c# xml

这是我的代码:

XmlDocument doc = new XmlDocument();
foreach (string c in colorList)
{
     doc.Load(@"http://whoisxmlapi.com/whoisserver/WhoisService?domainName=" + c + @"&username=user&password=pass");
     textBox1.Text += doc.SelectSingleNode("WhoisRecord/registrant/email").InnerText + ",";
}
Run Code Online (Sandbox Code Playgroud)

对于第二行代码(textbox1 ...)正在生成此错误我做错了什么?

Zac*_*son 6

将线路分开来查看异常发生的位置怎么样?

// if node is null the problem is with SelectSingleNode 
XmlNode node = doc.SelectSingleNode("WhoisRecord/registrant/email");

// if text is null the problem is with the node 
string text = node.InnerText;

// if textBox1 is null the problem is with textBox1
textBox1.Text += text + ",";
Run Code Online (Sandbox Code Playgroud)