XmlReader on windows phone application

caday32

New Member
I have a file data.xml in Isolated Storage and read file like this:\[code\]private const string DataFilePath = "data.xml";public void ReadFromFile() { _todoItems.Clear(); string s = ""; using (IsolatedStorageFile storageFile = IsolatedStorageFile.GetUserStoreForApplication()) { if(storageFile.FileExists(DataFilePath)) { using ( var fileStream = new IsolatedStorageFileStream(DataFilePath, FileMode.Open, storageFile)) { using(var streamReader = new StreamReader(fileStream)) { string text = streamReader.ReadToEnd(); using (XmlReader reader = XmlReader.Create( new StringReader(text))) { while (reader.Read()) { // Only detect start elements. if (reader.IsStartElement()) { // Get element name and switch on it. switch (reader.Name) { case "TodoList": // Detect this element. break; case "Item": break; case "Component": break; case "Name": if (reader.Read()) s += reader.Value.Trim() + "----"; break; } } } } } } } } }\[/code\]It only read element "TodoList", it dont't run read element "Item", "Component", "Name". But I read like this in windows form application, It read to element "Name".Where is errors?
 
Back
Top