Windows Phone xna game, how to save XML retrieved from web service

JediBubba

New Member
All, I'm working on a windows phone game that grabs some XML data from a remote web service prior to the game loading. This updates some of the data the game uses from time to time. That part works just fine. Once it grabs the data from the web service, I'm using:\[code\] void Response_Completed(IAsyncResult result) { HttpWebRequest request = (HttpWebRequest)result.AsyncState; HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(result); using (StreamReader streamReader = new StreamReader(response.GetResponseStream())) { string xml = streamReader.ReadToEnd(); using (XmlReader reader = XmlReader.Create(new StringReader(xml))) { reader.MoveToContent(); reader.GetAttribute(0); reader.MoveToContent(); webMessage = reader.ReadInnerXml();\[/code\]So now I've got a string of the XML in the webMessage string variable. I then write that to a file in IsolatedStorage. Again works great. My problem is when I go to read the data in:\[code\]using (IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication()){using (IsolatedStorageFileStream stream = myIsolatedStorage.OpenFile("Test.xml", FileMode.Open)) {XmlSerializer serializer = new XmlSerializer(typeof(List<Item>));List<Item> data = http://stackoverflow.com/questions/10436226/(List<Item>)serializer.Deserialize(stream);foreach (Item item in data){ System.Diagnostics.Debug.WriteLine(item.Item);}} }\[/code\]So the issue is when the file gets written to isolated storage, it's escaping all the XML markup, so when I go to read the file, instead of "<" it's reading %lt; etc, which causes the deserialize to crap out and report invalid characters. I'm really trying to avoid looping though the XML that I grabbed from the web service, that seems wasteful, I know it's valid XML from my own server. Does anyone know of a way to take that XML I'm getting from the web service and write it to a file in IsolatedStorage all in one shot?Thanks in advance.
 
Back
Top