I got this error "Data at the root level is invalid. Line 1, position 1" when I tried to read an XML file using C#.
Initially I was checking whether the XML is well formed and tried opening in IE to make sure whether it opens fine. IE didn't show any errors and my XML document was fine.
I couldn't figure out what's gone wrong. After a few minutes I realised that I was using XML.LoadXML() instead of XML.Load().
Actually I had my code initially to load an XML string so I was using XML.LoadXML() but changed the logic to load an XML document but forgot to change the code to XML.Load().
XML.Load() - to load an XML File
XML.LoadXML() - to load a XML String