XmlException: Document element did not appear. Line 1, position 1.

Feb 22, 2016 at 12:56 PM
I have this persisting issue even with the most minimal (validated) KML file.
The code that should load the KML file is this:
TextReader tr = File.OpenText(Application.streamingAssetsPath + "/" + kmlFileName);
string content = tr.ReadToEnd();
kmlFile = KmlFile.Load(tr);
I tried all kinds of kml file, from Google KML examples to manually generated minimal files and the issue persists.

Any ideas?
Feb 22, 2016 at 1:51 PM
Edited Feb 22, 2016 at 2:03 PM
OK, trouble solved.
I just commented out the line
string content = tr.ReadToEnd();
and it worked.

KmlFile class takes care of reading the file later on.
I think ReadToEnd was causing the file pointer to be at the end.

The error is quite confusing though, but this should be imputed to .Net / Mono implementations.