I've got the following XML passed as an IQueryable to a method, i.e.
XML:
<body>
<p>Some Text</p>
<p>Some Text</p>
<pullquote>This is pullquote</pullquote>
<p>Some Text</p>
<p>Some Text</p>
<body>
Method:
public static string CreateSection(IQueryable<XElement> section)
{
var bodySection = from b in articleSection.Descendants("body")
select b;
//Do replacement here.
var bodyElements = bodySection.Descendants();
StringBuilder paragraphBuilder = new StringBuilder();
foreach (XElement paragraph in bodyElements)
{
paragraphBuilder.Append(paragraph.ToString());
}
return paragraphBuilder.ToString();
}
What I want to accomplish is to replace the <pullquote>
with a <p>
(and maybe add attributes).
My problem is not the actual replacement (XElement.ReplaceWith()) but the fact that after the replacement the changes does not reflect the bodySection variable that gets used by the StringBuilder.
How would I go about getting this to work?