XML错误:根级的数据无效

时间:2022-07-19 18:33:41

I am getting this error:

我得到了这个错误:

Data at the root level is invalid. Line 1, position 1.

根级的数据无效。1号线,位置1。

Here's my code:

这是我的代码:

XmlDocument doc = new XmlDocument();

foreach (string c in colorList)
{
    doc.LoadXml("http://whoisxmlapi.com/whoisserver/WhoisService?domainName=" +
        c + "&username=user&password=pass");
    textBox1.Text += doc.SelectSingleNode(
        "/WhoisRecord/registrant/email").InnerText + ",";
}

Anyone know why I'm getting this exception?

有人知道我为什么会有这个例外吗?

I've tried to run the URL in the browser without any problems

我尝试在浏览器中运行URL,没有任何问题

1 个解决方案

#1


11  

use doc.Load("http:...")
LoadXml is for XML strings, not URLs

使用doc.Load(“http:…”)LoadXml是用于XML字符串,而不是url

#1


11  

use doc.Load("http:...")
LoadXml is for XML strings, not URLs

使用doc.Load(“http:…”)LoadXml是用于XML字符串,而不是url