【发布时间】:2011-05-12 07:57:24
【问题描述】:
我有一个 XML 文件,例如:
<myPrefix:Catalog xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:myPrefix="clr-namespace:........">
<myPrefix:Item Name="Item1" Mode="All" />
<myPrefix:Item Name="Item2" Mode="Single" />
</myPrefix:Catalog>
使用 C# 我创建了一个新项目,例如:
XContainer container = XElement.Parse(xml);
XElement xmlTree =
new XElement("Item",
new XAttribute("Name", item.Name),
new XAttribute("Mode", item.Mode));
如您所见,我没有添加“myPrefix”前缀。谁能告诉我我该怎么做?我不想再次声明 xmlns。谢谢,彼得
【问题讨论】:
标签: c# .net xml linq-to-xml