【发布时间】:2019-08-13 06:12:51
【问题描述】:
我无法使用 XElement 将字符串变量的值写入 .xml 文件。
我尝试使用System.IO:
XDocument,XElement
code.cs:
string variable ="sth";
XDocument xml_cip_c1 = new XDocument(
new XComment("document"),
new XElement("new root"),
new XElement("name", variable)
);
result.xml:
<!--document-->
<new root>
<name />
</new root>
【问题讨论】:
-
您在寻找
<name value = "ABC" />吗? -
我不知道如何在这里编辑帖子 // 变量字符串 variable ="sth";
-
点击帖子下方的edit按钮
-
@MichałParzych 如果以下答案之一解决了您的问题,请记住将其标记为已接受。