【发布时间】:2012-08-21 07:24:13
【问题描述】:
我在 LinqToXml 中创建新元素时遇到问题。 这是我的代码:
XNamespace xNam = "name";
XNamespace _schemaInstanceNamespace = @"http://www.w3.org/2001/XMLSchema-instance";
XElement orderElement = new XElement(xNam + "Example",
new XAttribute(XNamespace.Xmlns + "xsi", _schemaInstanceNamespace));
我想得到这个:
<name:Example xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
但在 XML 中我总是得到这个:
<Example xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="name">
我做错了什么?
【问题讨论】:
-
V4Vendetta:这是类似的问题,但现在我得到了这个:
<name:Example xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:name="name">
标签: c# .net xml linq-to-xml