我想知道读取xml文件并将内容保存在windows phone内存中的最好方法。
xml可在此链接中找到:
http://dl.dropbox.com/u/32613258/xml_example.xml
xml文件具有到诸如视频、图像和声音之类多媒体文件的链接。我已经将xml文件下载到存储电话中,我知道如何读取文件,但我不知道如何读取内容并将其保存到存储电话中。
我想从内存中读取xml,并选择xml中的所有链接,然后将图像、视频和声音下载到内存中。做到这一点的最好方法是什么?我将文件保存在独立存储中,是否可以保存在卡存储器中?
发布于 2011-11-05 06:18:09
首先,从XML文件中获取链接:
// using local XML file for demonstration
StreamResourceInfo info = Application.GetResourceStream(new Uri("xml_example.xml", UriKind.Relative));
XElement xml = XElement.Load(info.Stream);
// iterate media files
foreach (XElement element in xml.Element("graphics").Elements("file"))
{
// pick a video
if (element.Attribute("type").Value == "video")
{
// demoing that we found something
MessageBox.Show(element.Element("fileurl").Value);
// here goes the real action
DoSomethingUsefulWithURL(element.Element("fileurl").Value);
}
}然后继续下载并播放该文件,如本文所述:"Download, Store and Play Media files from Isolated Storage“。您的起点是从XML文件获得的URL。然后博客上的人就会做你想做的事。
https://stackoverflow.com/questions/8008678
复制相似问题