/// <summary> /// This function replaces strings in the plain text parts of the html. So tag names will not be replaced, just the plain content of the tags. /// </summary> /// <param name="HtmlInput">The Html-String you want to replace strings in.</param> /// <param name="TextReplacementMap">Dictionary in which the strings and the replacements of them are defined. /// (Form: Key-OldString, Value-NewString) If you want to remove a string, just replace it with a clear string.</param> /// <returns></returns> public string ReplaceStringsFromPlainTextElements(string HtmlInput, Dictionary<string, string> TextReplacementMap) { HtmlTag root = new HtmlTag(null, false, "root"); HtmlConstruct children = Analyze(HtmlInput, root); root.AddChildren(children.elements); IHtmlTagIterator iterator = root.getIterator(); while (iterator.hasNext()) { HtmlElement element = iterator.next(); if (element.GetType() == typeof(HtmlPlainText)) { HtmlPlainText PlainText = ((HtmlPlainText)element); foreach (KeyValuePair<string, string> MapItem in TextReplacementMap) { PlainText.content = PlainText.content.Replace(MapItem.Key, MapItem.Value); } } } return new HtmlConstruct(root.children).ToString(); }