title: How to replace an Paragraph's text using OpenXML Sdk
body: <p>I am parsing some Openxml word documents using the .Net OpenXml SDK 2.0. I need to replace certain sentences with other sentences as part of the processing. While iterating over the paragraphs, I know when I've found something I need to replace, but I am stumped as to how I can replace it. </p>
  
  <p>For example, lets say I need to replace the sentence <code>"a contract exclusively for construction work that is not building work."</code> with a html snippet to a Sharepoint Reusable content below.</p>
  
  <p><code>&lt;span class="ms-rtestate-read  ms-reusableTextView" contentEditable="false" id="__publishingReusableFragment" fragmentid="/Sites/Sandbox/ReusableContent/132_.000" &gt;a contract exclusively for construction work that is not building work.&lt;/span&gt;</code></p>
  
  <p>PS: I got the docx to Html conversion worked out using xslt, so that is kind of not a problem at this stage</p>
  
  <p>The InnerText property of the Paragraph node gives me the proper text, but the inner text property itself is not settable. So 
     <code> Regex.Match(currentParagraph.InnerText, currentString).Success</code>
  returns true and tells me that the current paragraph contains the text I want.</p>
  
  <p>As I said, InnerText itself is not settable, so I tried created a new paragraph using outerxml is given below.</p>
  
  <pre><code>string modifiedOuterxml = Regex.Replace(currentParagraph.OuterXml, currentString, reusableContentString);
  OpenXmlElement parent = currentParagraph.Parent;
  Paragraph modifiedParagraph = new Paragraph(modifiedOuterxml);
  parent.ReplaceChild&lt;Paragraph&gt;(modifiedParagraph, currentParagraph);
  </code></pre>
  
  <p>Even though I am not too concerned about the formatting at this level and it doesn't seem to have any, the outerXML seems to have extra elements that defeat the regex. </p>
  
  <p><code>
  ..."16" /&gt;&lt;w:lang w:val="en-AU" /&gt;&lt;/w:rPr&gt;&lt;w:t&gt;a&lt;/w:t&gt;&lt;/w:r&gt;&lt;w:proofErr w:type="gramEnd" /&gt;        &lt;w:r w:rsidRPr="00C73B58"&gt;&lt;w:rPr&gt;&lt;w:sz w:val="16" /&gt;&lt;w:szCs w:val="16" /&gt;&lt;w:lang w:val="en-AU" /&gt;&lt;/w:rPr&gt;&lt;w:t xml:space="preserve"&gt; contract exclusively for construction work that is not building work.&lt;/w:t&gt;&lt;/w:r&gt;&lt;/w:p&gt;</code></p>
  
  <p>So in summary, how would I replace the text in a Paragraph of OpenXml with other text. Even at the expense of losing some of the formatting.</p>