【发布时间】:2011-01-25 05:32:33
【问题描述】:
我遇到了我认为可能是一个非常简单的问题,在开发我的第一个 WP7 应用程序时,我已经到了访问我的站点的 api 和解析 XML 的阶段,但是我只是在尝试使用 XDocument。
我四处搜索,发现这个示例代码:Load an XML file from a website into XDocument (Silverlight and Windows Phone 7) 但 XDocument 类型不存在,我知道它应该存在于我正在使用的 System.Xml 命名空间中,但错误仍然存在,我有什么错过了吗?
在 Visual Studio 2010 Express for Windows Phone 上开发,该类的代码如下:
using System;
using System.Net;
using System.IO;
using System.Xml;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
namespace Application
{
public class DataRetriever
{
public void parseNewsXML()
{
WebClient client = new WebClient();
client.OpenReadCompleted += (sender, e) =>
{
if (e.Error != null)
return;
Stream str = e.Result;
XDocument xdoc = XDocument.Load(str);
};
}
}
抛出的确切错误是: 错误 1 找不到类型或命名空间名称“XDocument”(您是否缺少 using 指令或程序集引用?)
提前致谢
【问题讨论】:
标签: c# xml windows-phone-7