I have two nodes that have inner HTML that goes something like this:
Node1:
<p>some text</p>
<p>some more text</p>
Node2:
<p>some text</p>
<p>some more text</p>
<div><p>lots of more paragraphs here</p></div>
I'm trying to look up Node1 in Node2 in order to add <!--more-->
tag (for WordPress posts) following the first two paragraphs (or whatever HTML text is supplied in Node1).
Both of the above nodes have different parents. How do I find and replace or otherwise append the <!--more-->
tag in such case? I tried running the following code, but it errors out:
Code:
node2.ParentNode.ReplaceChild(HtmlNode.CreateNode(node1.InnerHtml & "<!--more-->"), node1).InnerHtml
Error:
Node "
" was not found in the collection
Parameter name: node
Also tried chaging node1
in the oldChild part to HtmlNode.CreateNode(node1.InnerHtml)
but that didn't work either.