开发者

How to add attributes to an element using LINQ, C#?

开发者 https://www.devze.com 2022-12-23 15:53 出处:网络
I ha开发者_StackOverflowve an XElement object which has a number of attributes and I simply want to add another attribute to the element.

I ha开发者_StackOverflowve an XElement object which has a number of attributes and I simply want to add another attribute to the element.

How do I do this?


xElement.Add(new XAttribute("Foo", "Bar"));


To create an element with an attribute use:
var xmlTest = new XElement("XmlElementName", new XAttribute("XmlAttributeName", "AttributeValue"));

0

精彩评论

暂无评论...
验证码 换一张
取 消