0
私は基本的なhtmlのxelementを持っています。私は段落タグであるすべての要素をすばやくループして、スタイル属性を設定したり追加したいと考えています。私は以下のことをしていますが、マスターxelementを変更していません。どのように私はこの作品を作ることができますか?XElementの変更は、どのように属性を編集しますか?
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;");
}
}