首先您从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。然后来自博客的人和你想要的几乎一样。
谢谢;)作品非常好;)一个简单的例子和简单易懂;)作品像一个魅力;) – jpmd
感谢您的反馈,并乐意帮助! :) –
在图像我有多个链接的情况下..我想存储所有的链接,以便以后在其他地方使用它..现在的XML只有4个图像,但未来可能有10个或更多。所以我想保存链接以便将内容保存到内存中。你可以帮我吗?我不知道我是否将这些项存储在数组中或者类似的东西中。或者可以创建一个图像类,另一个视频和其他音频,并将该分类存储到该类中。希望您不理解我的英语;) – jpmd