我正在使用 C# 和 XDcoument 将节点添加到根元素。我使用这段代码:
XElement miAnimalNuevo = new XElement("PrincipalNode",
new XAttribute("Atribute1", "value attribute 1"),
new XAttribute("Attribute2", "value attribute 2"),
new XElement("subNode","0000"));
但我明白了:
<PrincipalNode Atribute1="value attribute 1" Attribute2="value attribute 2" xmlns="">
<subNode>0000</subNode>
</PrincipalNode>
在属性 2 之后,我看到了 xmlns=""。为什么?我只想要属性。
谢谢。