【发布时间】:2010-10-21 18:53:30
【问题描述】:
我正在尝试使用此 ocde 读取 XML 文档文件 (C#) -
类型 classType = typeof(Point);
string documentationFileLocation = classType.Assembly.CodeBase;
if ( !string.IsNullOrEmpty(documentationFileLocation) && documentationFileLocation.StartsWith("file:///") )
{
documentationFileLocation = documentationFileLocation.Replace(".exe",".xml");
documentationFileLocation = documentationFileLocation.Replace("file:///","");
if(File.Exists(documentationFileLocation))
{
XElement document = XElement.Load(documentationFileLocation);
// Some Code Logic Here using LINQ
}
else
{
Console.WriteLine("Please Go to Project Properties->Build and check 'XML Documentation file'");
我在 XElement 文档 = XElement.Load(sr) 之后有一个 LINQ 查询,但它不起作用,
所以我在 LINQ 查询中放置了一个断点,我收到了这个错误 -
XmlException - 根级别的数据无效。第 1 行,位置 1。
我该如何解决?
编辑:稍微更改了代码 - 刚刚删除了 StreamReader
【问题讨论】: