title: OpenXML Find Variables within Word doc and replace them
body: <p>I need to search a document for strings enclosed in &lt;>. So if the application finds the variable  within the document, it replaces that variable with DateTime.Today.ToShortDateString(). For instance:</p>
  
  <pre><code>string filename = "C:\\Temp\\" + appNum + "_ReceiptOfApplicationLtr.docx";
  if (File.Exists((string)filename))
  {
      using (WordprocessingDocument wordDoc = WordprocessingDocument.Open(filename, true))
      {
          var body = wordDoc.MainDocumentPart.Document.Body;
          foreach (var text in body.Descendants&lt;Text&gt;())
          {
              if (text.Text == "&lt;TodaysDate&gt;")
              {
                  text.Text = text.Text.Replace("&lt;TodaysDate&gt;", DateTime.Today.ToShortDateString());
              }
          }
          using (StreamWriter sw = new StreamWriter(wordDoc.MainDocumentPart.GetStream(FileMode.Create)))
          {
              sw.Write(filename);
          }
      }
  }
  </code></pre>
  
  <p>Well when it searches the Descendants Text, it finds the first &lt;, then TodaysDate, finally >. The issue being it won't find the string <code>&lt;TodaysDate&gt;</code>. Can anyone help me out?</p>