ContentFiltering.Office.Word.Cleaners.BodyContentExtractor.Clean C# (CSharp) Method

Clean() public method

Gets the content between the opening and closing html tags.
public Clean ( string htmlCode ) : string
htmlCode string The html source to be
return string
        public string Clean(string htmlCode)
        {
            //Delete header & footer
            int startIndex, endIndex;
            startIndex = htmlCode.IndexOf("<body");
            endIndex = htmlCode.IndexOf(">", startIndex);
            htmlCode = htmlCode.Remove(0, endIndex + 1);
            startIndex = htmlCode.IndexOf("</body");
            if (startIndex >= 0)
                htmlCode = htmlCode.Remove(startIndex);
            return htmlCode;
        }

Usage Example

 public void TestCleaner()
 {
     IHTMLCleaner bodyContentExctractor = new BodyContentExtractor();
     initialHTML = bodyContentExctractor.Clean(initialHTML);
     Assert.AreEqual(initialHTML, expectedHTML);
 }
BodyContentExtractor