I want to select elements from XDocument and add an attribute to each in a single lambda expression. This is what I’m trying:
xhtml.Root.Descendants()
.Where(e => e.Attribute("documentref") != null)
.Select(e => e.Add(new XAttribute("documenttype", e.Attribute("documentref").Value)));
What is the correct way to do this?
Thanks!
1 Answer