【发布时间】:2013-10-06 23:27:25
【问题描述】:
我的 XML 文件格式为:
"<TestFile fileext="C:\TestFiles\TestFile2.txt">
</TestFile>"
这里的根元素是“TestFile”。我的任务是创建一个这种形式的新 XML,我使用的查询是:
XDocument doc = new XDocument(
new XDeclaration("1.0", "utf-8", "yes"),
new XComment("This is a medtata file of the file " + args[0]),
new XElement("TestFile",path));
但不是
"<TestFile fileext="C:\TestFiles\TestFile2.txt">
</TestFile>"
,输出为
"<TestFile>C:\TestFiles\TestFile2.txt</TestFile>"
我怎样才能得到想要的输出?
【问题讨论】:
-
我在这里得到了答案:stackoverflow.com/questions/7931650/… 谢谢
标签: c# linq-to-xml