Xml多媒体内容下载

时间:2011-11-04 11:38:27

标签: xml windows-phone-7 multimedia

我想知道读取xml文件并将内容保存在Windows手机内存中的最佳方法。

xml在此链接中可用:

http://dl.dropbox.com/u/32613258/xml_example.xml

xml文件包含视频,图像和声音等多媒体文件的链接。我已经将xml文件下载到内存电话,我知道如何读取文件,但我不知道如何阅读内容并将其保存到内存电话中。

我想从内存中读取xml并选择xml中的所有链接,然后将图像,视频和声音下载到内存中。最好的方法是什么?我将文件保存在独立存储器中,可以保存在卡存储器中吗?

1 个答案:

答案 0 :(得分:1)

首先,您从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。然后来自博客的那个人就像你想要的一样。