jjzjj

EmployeeConfiguration

全部标签

c# - 如何有条件地以不太冗长的方式写出 XML?

我想用C#写一个xml文件。这是一个像这样的基本文件:如果没有Employee节点,我不想有Employees节点...我想使用XElement但我不能因为那个...所以我使用了XmlWriter。它工作正常,但我发现编写XML非常冗长:EmployeeConfigurationconfig=EmployeeConfiguration.GetConfiguration();using(XmlWriterwriter=XmlWriter.Create(_fileUri,settings)){writer.WriteStartDocument();//writer.WriteStartEl