C# 无法从我的Api读取Xml,因为根级别的错误数据无效。第1行,位置1
每次我试图从数据库web api(我创建的)中提取XML时,XMLTextReader.Read()都会给出一个错误提示 根级别的数据无效。第1行,位置1 我的XmlReader代码是:C# 无法从我的Api读取Xml,因为根级别的错误数据无效。第1行,位置1,c#,xml,xmlreader,C#,Xml,Xmlreader,每次我试图从数据库web api(我创建的)中提取XML时,XMLTextReader.Read()都会给出一个错误提示 根级别的数据无效。第1行,位置1 我的XmlReader代码是: String URLString = @"https://localhost:44331/api/voter/4220180288473"; XmlTextReader reader = new XmlTextReader(URLString); reader.MoveToNextAttribute(); wh
String URLString = @"https://localhost:44331/api/voter/4220180288473";
XmlTextReader reader = new XmlTextReader(URLString);
reader.MoveToNextAttribute();
while (reader.Read())
{
// Do some work here on the data.
Console.WriteLine(reader.Name);
}
Console.ReadLine();
我的XML:
泽山穆斯塔法
1234
基尔
4220180288476
假的
我运行了您的代码,当我使用此url字符串时,它似乎工作正常:确保数据开头没有任何白色字符。