XmlException: Root element is missing

The cause of the XmlException entitled Root element is missing means the XML document you’re trying to load is not formatted properly, more exactly it’s missing the root node.
Each XML file must have a root element / node which encloses all the other elements.

The following is an example of an XML file which is not properly formed:

<Language name="C#"></Language>
<Language name="VB.NET"></Language>

And here is the same XML file, formed properly:

<?xml version="1.0" encoding="utf-8"?>
<Languages>
<Language name="C#"></Language>
<Language name="VB.NET"></Language>
</Languages>

Also, a blank XML file will return the same Root elements is missing exception. Each XML file must have a root element / node which encloses all the other elements.

Also, a blank XML file will return the same Root elements is missing exception.

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top