StringBuilder returnXml = new StringBuilder();
returnXml.Append("DATE TIME,FUNCTION,TOTAL\n");
String Date = "", Function = "", Total = "";
StreamReader xmlStream = getBlobData(logType, serial, blobStorageCredentials);
//string adf = xmlStream.ReadToEnd();
XmlReader xmlReader = XmlReader.Create(xmlStream);
while (xmlReader.Read())
{
switch (xmlReader.Name)
{
case "OperationType":
if (xmlReader.NodeType == XmlNodeType.Element)
Function = xmlReader.ReadElementContentAsString();
break;
case "TotalCounter":
if (xmlReader.NodeType == XmlNodeType.Element)
Total = xmlReader.ReadElementContentAsString();
break;
case "LogDateTime":
if (xmlReader.NodeType == XmlNodeType.Element)
Date = xmlReader.ReadElementContentAsString();
break;
case "Entries":
if (xmlReader.NodeType == XmlNodeType.EndElement)
{
returnXml.Append(Date);
returnXml.Append(",");
returnXml.Append(Function);
returnXml.Append(",");
returnXml.Append(Total);
returnXml.Append("\n");
}
break;
default:
break;
}
}
return returnXml.ToString();
所以所有这些案件都没有被输入。如果我评论:
//string xmlString = xmlStream.ReadToEnd();
然后 xmlString 在调试器中是这样的(看起来是正确的):
为什么 XmlReader 认为所有的节点都是 EndElements?我很挣扎,因为这不是我的代码。交给我了...