C# 如何在特殊索引处为HtmleElement追加子项

C# 如何在特殊索引处为HtmleElement追加子项,c#,webbrowser-control,appendchild,htmlelements,C#,Webbrowser Control,Appendchild,Htmlelements,我正在使用.NET WebBrowser控件作为所见即所得html编辑器。 现在我想用链接替换HtmleElement中的特殊字符串。 我使用的是这个代码 foreach (var el in nodes) { string innertxt = el.InnerText; MatchCollection matches = Regex.Matches(innertxt, pattern); foreach (Match match in matches) {

我正在使用.NET WebBrowser控件作为所见即所得html编辑器。 现在我想用链接替换HtmleElement中的特殊字符串。 我使用的是这个代码

foreach (var el in nodes)
{
    string innertxt = el.InnerText;
    MatchCollection matches = Regex.Matches(innertxt, pattern);
    foreach (Match match in matches)
    {
        string finalLink = FinalWordLink(word_current, linkTemp);
        int indexWord = match.Index;
        int lenghWord = match.Length;
        el.InnerText = el.InnerText.Remove(indexWord, lenghWord);
        el.InnerText = el.InnerText.Insert(indexWord, finalLink);
    }
}
但我现在不工作,并显示新的链接作为一个文本 我有一个问题,我不想替换innerhtml,因为这不好,可能会替换错误的字符串,如标记、类等 我知道如何在HtmleElement中附加child,如下所示:

HtmlElement elem = HTMLEditor.Document.CreateElement("a");
elem.SetAttribute("href", "www.google.com");
elem.InnerText = "Click here";

el.AppendChild(elem);
但如何在find索引中追加child