Alex Gordon
Alex Gordon

Reputation: 60691

XML error: data at root level is invalid

I am getting this error:

Data at the root level is invalid. Line 1, position 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

Upvotes: 1

Views: 1844

Answers (1)

Marvin Smit
Marvin Smit

Reputation: 4108

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

Upvotes: 11

Related Questions