I have an xelement which is basic html, i want to quickly loop through all the elements that are paragraph tags and set the style attribute or append to it. I am doing what is below, but it is not changing the master xelement. How can i make this work?
XElement ele = XElement.Parse(body);
foreach (XElement pot in ele.DescendantsAndSelf("p"))
{
if (pot.Attribute("style") != null)
{
pot.SetAttributeValue("style", pot.Attribute("style").Value + " margin: 0px;");
}
else
{
pot.SetAttributeValue("style", "margin: 0px;");
}
}