XDocument.Load() scenarios with System.Xml.XmlException on Valid XML File - Nested Elements guide
I'm having trouble loading an XML file using `XDocument.Load()` in C#. Although the XML file appears to be well-formed, I keep working with a `System.Xml.XmlException` with the message 'Root element is missing.' This is particularly puzzling because I can open the file in an XML editor without any scenario. My XML file looks like this: ```xml <?xml version="1.0" encoding="utf-8"?> <root> <element> <child>Value</child> <nested> <child>Another Value</child> </nested> </element> </root> ``` When attempting to load the XML, I use the following code: ```csharp XDocument doc = XDocument.Load("path/to/your/file.xml"); ``` I've verified the file path is correct and that the file is not empty prior to loading. I've also tried using `using (var reader = new StreamReader("path/to/your/file.xml")) { var doc = XDocument.Load(reader); }` but the same exception is raised. When I debug, it seems like the file is read correctly, but the exception is thrown right at the loading point. I've checked for any invisible characters or BOM markers at the start of the file. Is there something specific I might be overlooking with nested XML elements or encoding settings? Any help would be greatly appreciated! I'd really appreciate any guidance on this.