2
Vote

InnerText for Comment node returns comment text

description

I note that InnerText for Comment node returns comment text, which I regard as wrong. InnerText should normally return a plaintext representation of what is visible on screen.
 
To avoid breaking code, I suggest adding a document option:
OptionCommentInnerTextAsEmpty
which if set to true would force an empty string to be returned for comment nodes.
 
i.e. in InnerText in HtmlNode.cs
 
            if (_nodetype == HtmlNodeType.Comment)
                if (_ownerdocument.OptionCommentInnerTextAsEmpty)
                    return string.Empty;
                else
                    return ((HtmlCommentNode)this).Comment;

comments