25

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");
TylerH
  • 20,799
  • 66
  • 75
  • 101
sari k
  • 2,051
  • 6
  • 28
  • 34

1 Answers1

57

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

John Saunders
  • 160,644
  • 26
  • 247
  • 397