title: Replacing in inner Text in open xml element?
body: <p>I'm using open xml SDK 2.0 and i'm kind off new to this.</p>
  
  <p>I have actually created a quickpart (containg content control) in my word 2007 document named "hello.docx". Now I need to copy the quickpart into the other location of the same document named "hello.docx". I was very thank full for this post <a href="http://www.techques.com/question/1-3448297/Replacing-Content-Controls-in-OpenXML" rel="nofollow noreferrer">http://www.techques.com/question/1-3448297/Replacing-Content-Controls-in-OpenXML</a> and same thing is posted on stack overflow forum for which i was very thank full :)...This post just deletes the content control but keeps the content in Content control.</p>
  
  <p>With the help of the above link I was able to modify the code to clone the content control and append to the same document (This part of my code is working). But i have problem in innerText. Though i replace the innerText in the open Xml element, it is not geting reflected in the doucument. </p>
  
  <pre><code>public static void AddingSdtBlock(string filename, string sdtBlockTag)
  {
      using (WordprocessingDocument doc = WordprocessingDocument.Open(filename,true))
      {
          MainDocumentPart mainDocumentPart = doc.MainDocumentPart;
          List&lt;SdtBlock&gt; sdtList = mainDocumentPart.Document.Descendants&lt;SdtBlock&gt;().ToList();
          SdtBlock sdtA = null;
  
          foreach (SdtBlock sdt in sdtList)
          {
              if (sdt.SdtProperties.GetFirstChild&lt;Tag&gt;().Val.Value == sdtBlockTag)
              {
                  sdtA = sdt;
                  break;
              }
          }
          SdtBlock cloneSdkt = (SdtBlock)sdtA.Clone();
  
  
  
          OpenXmlElement sdtc = cloneSdkt.GetFirstChild&lt;SdtContentBlock&gt;();
        //  OpenXmlElement parent = cloneSdkt.Parent;
  
          OpenXmlElementList elements = cloneSdkt.ChildElements;
  
         // var mySdtc = new SdtContentBlock(cloneSdkt.OuterXml);
  
          foreach (OpenXmlElement elem in elements)
          {
            string innerxml=  elem.InnerText ;
            if (innerxml.Length&gt;0)
            {
                string modified = "Class Name : My Class.Description : mydesc.AttributesNameDescriptionMy Attri name.my attri desc.Operations NameDescriptionmy ope name.my ope descriptn.";
               string replace= elem.InnerText.Replace(innerxml, modified);
              // mainDocumentPart.Document.Save();
            }
             // string text = parent.FirstChild.InnerText;
             // parent.Append((OpenXmlElement)elem.Clone());
          }
  
          mainDocumentPart.Document.Body.AppendChild&lt;SdtBlock&gt;(cloneSdkt);
  
          //sdtA.Remove();
      }
  }
  </code></pre>
  
  <p>The Replaced string in the openXML element is not geting reflected in the document. Any help would be really appreciated.</p>
  
  <p>Thanks in advance,</p>