【发布时间】:2013-02-12 19:59:50
【问题描述】:
我试过了:
textBox1.Text = new XDocument(new XDeclaration("1.0", "UTF-8", "yes"),
new XElement("root1", new XAttribute( "xmlns", @"http://example.com"), new XElement("a", "b"))
).ToString();
但我明白了:
The prefix '' cannot be redefined from '' to 'http://example.com' within the same start element tag.
我也尝试过替换(根据我找到的答案):
XAttribute(XNamespace.Xmlns,...
但也出现了错误。
注意:我不想在文档中包含多个 xmlns。
【问题讨论】:
标签: c# .net xml xml-namespaces linq-to-xml