sari k
sari k

Reputation: 2111

Data at the root level is invalid. Line 1, position 1 -why do I get this error while loading an xml file?

Data at the root level is invalid. Line 1, position 1 -why I get this error while load xml file

this my code:

XmlDocument xmlDoc=new XmlDocument();
xmlDoc.LoadXml("file.xml");

Upvotes: 26

Views: 61955

Answers (1)

John Saunders
John Saunders

Reputation: 161773

The LoadXml method is for loading an XML string directly. You want to use the Load method instead.

Upvotes: 60

Related Questions