【发布时间】:2016-05-06 06:43:39
【问题描述】:
我正在为 Windows 10 移动版编写 UWP 应用。
我这样创建了 xml:
XmlDocument doc = new XmlDocument();
XmlElement el = (XmlElement)doc.AppendChild(doc.CreateElement("Order"));
el.SetAttribute("CallConfirm", "1");
el.SetAttribute("PayMethod", "");
el.SetAttribute("QtyPerson", "");
el.SetAttribute("Type", "1");
el.SetAttribute("PayStateID", "0");
el.SetAttribute("Remark", "{StreetName} , ..");
el.SetAttribute("RemarkMoney", "0");
el.SetAttribute("TimePlan", "");
el.SetAttribute("Brand", "1");
el.SetAttribute("DiscountPercent", "0");
el.SetAttribute("BonusAmount", "0");
el.SetAttribute("Department", "");
XmlElement el2 = (XmlElement)el.AppendChild(doc.CreateElement("Customer"));
el2.SetAttribute("Login", "");
el2.SetAttribute("FIO", "{FIO}");
XmlElement el3 = (XmlElement)el.AppendChild(doc.CreateElement("Address"));
el3.SetAttribute("CityName", "");
el3.SetAttribute("StationName", "");
el3.SetAttribute("StreetName", "{StreetName}");
el3.SetAttribute("House", "{HouseName}");
el3.SetAttribute("Corpus", "");
el3.SetAttribute("Building", "");
el3.SetAttribute("Flat", "{FlatName}");
el3.SetAttribute("Porch", "");
el3.SetAttribute("Floor", "");
el3.SetAttribute("DoorCode", "");
XmlElement el4 = (XmlElement)el.AppendChild(doc.CreateElement("Phone"));
el4.SetAttribute("Code", "{Code}");
el4.SetAttribute("Number", "{Phone}");
XmlElement el5 = (XmlElement)el.AppendChild(doc.CreateElement("Products"));
我想创建 .xml 文件并将这个 xml 写入其中。
我尝试像这样doc.Save("data.xml"); 保存它,但出现此错误
Error CS1503 Argument 1: cannot convert from 'string' to 'System.IO.Stream' Murakami
我怎样才能做到这一点?
非常感谢您的帮助!
【问题讨论】:
-
您是否尝试搜索如何保存
XmlDocument?你会得到很多结果! -
@CharlesMager 这是一个通用应用程序
-
@ЕвгенийСухомлин 这里有一些关于这个的帖子,我没有找到确切的欺骗,然后我只是给你举个例子:github.com/Microsoft/Windows-universal-samples/tree/master/…
标签: c# xml win-universal-app