加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – 找不到类型或命名空间名称“XmlDocument”.你错过了装配参

发布时间:2020-12-15 23:46:27 所属栏目:百科 来源:网络整理
导读:我正在尝试使用以下内容解析xml文档: XmlDocument doc = new XmlDocument ();doc.LoadXml (myXMLstring); 我收到错误: The type or namespace name ‘XmlDocument’ could not be found. Are you missing an assembly reference? ..尽管我有 使用System.Xm
我正在尝试使用以下内容解析xml文档:

XmlDocument doc = new XmlDocument ();
doc.LoadXml (myXMLstring);

我收到错误:

The type or namespace name ‘XmlDocument’ could not be
found. Are you missing an assembly reference?

..尽管我有
使用System.Xml;

我不确定装配参考是什么.我正在使用Xamarin Studio.我看到有几个文件夹供参考.在基础项目的references文件夹中,我没有看到System.Xml的条目

但在个别平台上,我确实看到了System.Xml.

我该怎么做才能清除此错误行?

解决方法

正如我在Xamarin论坛上发布的那样: http://forums.xamarin.com/discussion/46042/missing-assembly-reference-for-system-xml#latest

使用XDocument.Parse(string)从可移植类库中完成此操作.

XDocument包含在System.Xml.Linq命名空间中,因此您需要在类中添加该命名空间的using指令.

您无法从可移植类库(PCL)访问XmlDocument的原因是,PCL将仅公开PCL所针对的所有平台上支持的API. Windows Phone 8不支持XmlDocument,因此PCL中不提供此功能. Windows应用商店应用程序支持XmlDocument,但它在不同的命名空间(Windows.Data.Xml.Dom)中可用.因此,无法从PCL使用System.Xml.XmlDocument.通过PCL中的System.Xml命名空间提供的任何其他内容都可以使用.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读