private void EnsureMetaCharsetElement() { if (this._updateMetaCharset) { var syntax = this._outputSettings.GetSyntax; if (syntax == Syntax.html) { var metaCharset = Select("meta[charset]").First; if (metaCharset != null) { metaCharset.Attr("charset", GetEncoding().EncodingName); } else { if (Head != null) { Head.AppendElement("meta").Attr("charset", GetEncoding().EncodingName); } } // Remove obsolete elements Select("meta[name=charset]").Remove(); } } }