我试图在.NET Core中重新创建代码,但出现错误和突出显示,这无助于解决问题。
这是代码:
using System;
using System.IO;
using System.Xml;
public class Sample
{
public static void Main()
{
string content = File.ReadAllText("input.xml");
XmlDocument doc = new XmlDocument();
doc.LoadXml(content.Trim());
XmlWriter writer = XmlWriter.Create("output.xml");
doc.Save(writer);
}
}
我尝试将Referece“ System.Xml”添加到依赖项中,但是会产生新的错误。
Errors in .NET Core which do not happen to be in .NET 4.0
最佳答案
您需要从NuGet添加正确的软件包:System.Xml.XmlDocument
然后从命令行运行dotnet restore
(我真的不知道您是否/如何从VS中执行此操作)。
之后,Chien Dang回答了XmlWriter问题。
关于c# - .NET核心找不到XmlDocument,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/42456194/