的XDocument没有出现在System.Xml命名空间存在 [英] XDocument doesn't appear to exist in System.Xml namespace

查看:1552
本文介绍了的XDocument没有出现在System.Xml命名空间存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有什么,我想可能会是一个非常简单的问题,在发展我的首款WP7的应用程序我来访问我的网站的API和解析XML的阶段,但是我在想刚才绊倒。使用的XDocument

I'm having what I think will probably be a really simple problem, in developing my first WP7 app I've come to the stage of accessing my Site's api and parsing the XML, however I'm stumbling just at trying to use XDocument.

我搜索了一圈,发现这个例子的代码:的 http://stackoverflow.com/questions/4002989/load-xml-file-from-website-into-xdocument-silverlight-and-wp7 但的XDocument类型不存在,我的理解应该是在我使用System.Xml命名空间存在,但仍然存在错误,你有什么我错过了吗?

I search around and found this example code: http://stackoverflow.com/questions/4002989/load-xml-file-from-website-into-xdocument-silverlight-and-wp7 but the XDocument type does not exist, I understand it is supposed to exist in the System.Xml namespace which I am using, but the error still remains, what have I missed?

在Visual Studio 2010中Express的Windows Phone的开发,这个类代码如下:

Developing on Visual Studio 2010 Express for Windows Phone, code for this class is below:

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指令或程序集引用?)

Exact error being thrown is: Error 1 The type or namespace name 'XDocument' could not be found (are you missing a using directive or an assembly reference?)

在此先感谢

推荐答案

有关Silverlight中,这个类是 System.Xml.Linq.dll ,根据< A HREF =http://msdn.microsoft.com/en-us/library/system.xml.linq.xdocument%28v=VS.95%29.aspx> MSDN - 所以添加到参考 System.Xml.Linq.dll 。您还需要一个使用指令在代码文件的顶部:

For Silverlight, that class is in System.Xml.Linq.dll, according to MSDN - so add a reference to System.Xml.Linq.dll. You will also need a using directive at the top of your code file:

using System.Xml.Linq;



(这是完全一样的两个建议,编译器本身就是:你缺少using指令或程序集引用?)

(these are exactly the same two suggestions that the compiler itself makes: "are you missing a using directive or an assembly reference?")

这篇关于的XDocument没有出现在System.Xml命名空间存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆