Content Service

The Content Service is the most important service of this HTML Editor. The Editor gives various options to either retrieve the Editor content or to manipulate it through code. Below is the screenshot listing the sub-properties and methods of Content property.

Content Service

The TableAuthoringService sub-property of the Content property allows you get or set the values of the HTML table present in the Editor.

Content Service 2

Say, you want to change the content of all hyperlinks in your HTML. Here is a code snippet that shows how to iterate over all HTML Elements and modify the element.

but you can get all Hyperlink references from the HTML Body and manipulate the content of the hyperlinks. 
Here is an example snippet about how to manipulate the HTML elements.


IHTMLElementCollection allHTMLElements = wpfHtmlEditor1.Content.GetBodyIHTMLElements();
foreach (IHTMLElement anHtmlElement in allHTMLElements)
{
    if (anHtmlElement.tagName == "a")
    {
        string oldHref = anHtmlElement.getAttribute("href").ToString();
        string newHref = "https://www.google.ca";
        anHtmlElement.setAttribute("href", newHref);
    }
}
Last updated on Apr 21, 2020