InnerHtml works wrong!!!

Topics: User Forum
Jan 7, 2015 at 4:39 PM
i wirte some code in LINQPad:
void Main()
{
    var html = new HtmlDocument();
    html.OptionAutoCloseOnEnd = true;
    html.OptionWriteEmptyNodes = true;  
    html.OptionFixNestedTags = true;

    html.LoadHtml("<br />");
    html.DocumentNode.WriteContentTo().Dump();
    
    html.DocumentNode.InnerHtml = "<br />";
    html.DocumentNode.WriteContentTo().Dump();
}
output:
<br />
<br>
i changed the default options of the HtmlDocument, and i want the result is "<br />".
but with "InnerHtml" the result is "<br>", this isn't what i want.

why ?

i use ilspy to read the source code of InnerHtml :
public virtual string InnerHtml
{
    get...
    set
    {
        HtmlDocument doc = new HtmlDocument();
        doc.LoadHtml(value);
        this.RemoveAllChildren();
        this.AppendChildren(doc.DocumentNode.ChildNodes);
    }
}
it create a HtmlDocument object with default options, so the result is wrong!

i hope this will be fixed with the next release!