开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜