“Data at the Root Level is invalid” with LoadXml

前端 未结 3 1938
傲寒
傲寒 2021-01-24 09:32

I have a code snippet :

XmlDocument doc = new XmlDocument();
try
{
    doc.LoadXml(xmlPath);
}
catch (Exception ex)
{
    string exMessage = ex.Message; 
}
         


        
3条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-24 09:59

    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.

提交回复
热议问题