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();
因此,所有這些情況都不會被輸入。如果我評論:XmlReader認爲所有元素都是EndElements
//string xmlString = xmlStream.ReadToEnd();
隨後的xmlString這是在調試器(它看起來是正確的):
爲什麼XmlReader中認爲所有的節點都EndElements?我很掙扎,因爲這不是我的代碼。交給我......
看不到你的xml。鏈接超時。你可以發佈你的XML嗎? – ZafarYousafi 2012-08-04 02:22:48