title: Replace text inside any <p> tag html with C#
body: <p>I'm trying to replace any text that i have inside <code>&lt;p&gt;</code> tag, If i have the follow HTML:</p>
  
  <pre><code>&lt;p&gt;&lt;br /&gt;
  &lt;html&gt;&lt;br /&gt;
  &lt;body&gt;&lt;/p&gt;
  &lt;p&gt;&lt;h1&gt;My First JavaScript&lt;/h1&gt;&lt;/p&gt;
  &lt;p&gt;&lt;button type="button"&lt;br /&gt;
  onclick="document.getElementById('demo').innerHTML = Date()"&gt;&lt;br /&gt;
  Click me to display Date and Time.&lt;/button&gt;&lt;/p&gt;
  &lt;p&gt;&lt;p id="demo"&gt;&lt;/p&gt;&lt;/p&gt;
  &lt;p&gt;&lt;/body&gt;&lt;br /&gt;
  &lt;/html&gt; &lt;br /&gt;
  &lt;/p&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I want to change any text that inside the <code>&lt;p&gt;</code> tag and replace the special characters, What I'm tried:</p>
  
  <pre><code>string pTag = "&lt;p&gt;";
          int pLength = pTag.Length;
  
          int index = input.IndexOf(pTag, StringComparison.Ordinal);
          while (index &gt; 0)
          {
              int lastIndex = input.IndexOf("&lt;/p&gt;", index);
  
              if (lastIndex == index)
                  break;
              var subString = input.Substring(index + pLength, lastIndex - index - pLength);
              var newsubString = System.Security.SecurityElement.Escape(subString);
              input = input.Replace(subString, newsubString);
  
              index = lastIndex;
          }
  </code></pre>
  
  <p>But my code change only the first item,
  Any suggestions?</p>
  
  <p>Thanks!</p>