title: HtmlAgilityPack replace node
body: <p>I want to replace a node with a new node. How can I get the exact position of the node and do a complete replace?</p>
  
  <p>I've tried the following, but I can't figured out how to get the index of the node or which parent node to call <code>ReplaceChild()</code> on.</p>
  
  <pre><code>string html = "&lt;b&gt;bold_one&lt;/b&gt;&lt;strong&gt;strong&lt;/strong&gt;&lt;b&gt;bold_two&lt;/b&gt;";
  HtmlDocument document = new HtmlDocument();
  document.LoadHtml(html);
  
  var bolds = document.DocumentNode.Descendants().Where(item =&gt; item.Name == "b");
  
  foreach (var item in bolds)
  {
  
      string newNodeHtml = GenerateNewNodeHtml();
      HtmlNode newNode = new HtmlNode(HtmlNodeType.Text, document, ?);
      item.ParentNode.ReplaceChild( )
  }
  </code></pre>