24

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,816
  • 57
  • 73
  • 92
sari k
  • 1,991
  • 6
  • 26
  • 34

1 Answers1

57

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

John Saunders
  • 159,224
  • 26
  • 237
  • 393