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

2019-01-09 06:20发布

问题:

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");

回答1:

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