Reputation: 81262
I have a code snippet :
XmlDocument doc = new XmlDocument();
try
{
doc.LoadXml(xmlPath);
}
catch (Exception ex)
{
string exMessage = ex.Message;
}
The XML looks like this
<?xml version="1.0" encoding="UTF-8"?>
<MimeTypes>
<MimeType>
<Extension>.3dm</Extension>
<Value>x-world/x-3dmf</Value>
</MimeType>
</MimeTypes>
Its producing this error:
Data at the root level is invalid. Line 1, position 1.
Any idea what's wrong?
Upvotes: 1
Views: 2702
Reputation:
does xmlPath contains the whole xml or a path to a file that contains it? The LoadXml method expects the actual XML, not a path to a file. If you want to load the xml using a path, using the Load method.
Upvotes: 1
Reputation: 116654
You're passing a file path to a parameter that should contain the XML itself.
Upvotes: 3