internal static string RemoveInternalHTML()

in src/AccessibilityInsights.Extensions.AzureDevOps/FileIssue/FileIssueHelpers.cs [219:261]


        internal static string RemoveInternalHTML(string inputHTML, string keyText)
        {
            object[] htmlText = { inputHTML };
            HTMLDocument doc = new HTMLDocument();
            IHTMLDocument2 doc2 = doc as IHTMLDocument2;
            doc2.write(htmlText);
            IHTMLDOMNode node = null;

            // search div with matching issueguid.
            // remove any of it if there is matched one.
            var divnodes = doc.getElementsByTagName("div");

            if (divnodes != null)
            {
                foreach (IHTMLDOMNode divnode in divnodes)
                {
                    foreach (IHTMLDOMNode child in GetChildren(divnode))
                    {
                        string nodevalue = child.nodeValue?.ToString();
                        if (nodevalue != null && nodevalue.Contains(keyText) == true)
                        {
                            node = divnode;
                            break;
                        }
                    }

                    if (node != null)
                    {
                        break;
                    }
                }
            }

            if (node != null)
            {
                foreach (IHTMLDOMNode child in GetChildren(node).ToList())
                {
                    node.removeChild(child);
                }
            }

            return doc.body.outerHTML;
        }