XElement c = new XElement("Customers",
new XElement("Customer",
new XElement("Name", "John Doe"),
new XElement("PhoneNumbers",
new XElement("Phone",
new XAttribute("type", "home"),
"555-555-5555"),
new XElement("Phone",
new XAttribute("type", "work"),
"666-666-6666")
)
)
);
Console.WriteLine(c);
Linq to xml:XAttribute对象
最新推荐文章于 2025-10-13 16:00:16 发布
本文介绍了一种使用C#中的XElement类来构建XML数据结构的方法。通过实例展示了如何创建包含嵌套元素、属性及文本节点的XML数据。具体包括创建客户信息,如姓名、电话号码等。
515

被折叠的 条评论
为什么被折叠?



