草庐IT

EndDocument

全部标签

c# - 使用 .Save() 时,状态文档中的 token EndDocument 将导致无效的 XML 文档

我正在使用C#和Linq编写XML文件,但在尝试保存它时出现“状态文档中的tokenEndDocument将导致无效的XML文档”错误。文档的创建和保存代码:XDocumentxDoc=newXDocument();using(vardb=newCarRentalEntities1()){foreach(Carcindb.Cars){XElementroot=newXElement("root",newXElement("Car-"+c.CarName,newXAttribute("CarID",c.CarID),newXAttribute("CarName",c.CarName),n