1

您好我需要创建一些 XML 元素,例如:

<Example_Property xmlns:dt="urn:schemas-microsoft-com:datatypes" dt:dt="string">ExampleData</Example_Property>

但我的代码:

            XElement newElement = new XElement("Example_Property");

            XNamespace datatypes = "urn:schemas-microsoft-com:datatypes";

            newElement.Add(new XAttribute(datatypes + "dt", "string"));

            newElement.Value = "ExampleData";

到目前为止只创建:

<Example_Property dt:dt="string">ExampleData</Example_Property>

我必须如何使用命名空间?

提前致谢。

4

0 回答 0