Well, it sounds like it simply isn't a valid XML file.
If you print out the result of sr.ReadToEnd()
instead of calling XElement.Load
, what does it look like? If you try to load the file into an XML editor, what happens?
Btw, it's better to use a using
statement than calling Dispose
explicitly: with your current code, the StreamReader
isn't disposed if Load
throws an exception.
Finally, is there any reason you're not just using XElement.Load(documentationFileLocation)
?