0
我想從XDocument中選擇元素,並在單個lambda表達式中爲每個元素添加一個屬性。這是我想要的:C#Linq To Xml - 如何選擇元素集合並使用lambda修改每個元素?
xhtml.Root.Descendants()
.Where(e => e.Attribute("documentref") != null)
.Select(e => e.Add(new XAttribute("documenttype", e.Attribute("documentref").Value)));
什麼是正確的方法來做到這一點?
謝謝!