简体   繁体   English

找不到 XDocument 和 XElement

[英]Can't find XDocument and XElement

I'm trying to parse an xml and I want to get access to either XDocument or XElement .我正在尝试解析 xml 并且我想访问XDocumentXElement Those 2 classes currently don't exist.这两个类目前不存在。

I'm using Visual Studio.我正在使用 Visual Studio。 Am I suppose to add a reference?我想添加参考吗? I currently have System.Xml.linq selected but I still can't access the 2 classes above...我目前选择了 System.Xml.linq 但我仍然无法访问上面的 2 个类...

在此处输入图像描述

You need the System.Xml.XDocument.dll for XDocument and XElement .您需要System.Xml.XDocument.dll用于XDocumentXElement

See the docs :请参阅文档

在此处输入图像描述

If you don't have that dll on your system, you could install the System.Xml.XDocument NuGet package.如果您的系统上没有 dll,则可以安装System.Xml.XDocument NuGet ZEFE90A8E604A7F67B40.A3

Install-Package System.Xml.XDocument -Version 4.3.0

PS: To read more how to install NuGet packages in Visual Studio, check Quickstart: Install and use a package in Visual Studio PS:要了解更多如何在 Visual Studio 中安装 NuGet 包,请查看快速入门:在 Visual Studio 中安装和使用 package

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM