AngleSharp by AngleSharp

<PackageReference Include="AngleSharp" Version="0.9.11" />

 SvgDocument

Represents a document node that contains only SVG nodes.
using AngleSharp.Dom.Events; using AngleSharp.Extensions; using AngleSharp.Network; using AngleSharp.Parser.Xml; using AngleSharp.Services; using System; using System.Threading; using System.Threading.Tasks; namespace AngleSharp.Dom.Svg { internal sealed class SvgDocument : Document, ISvgDocument, IDocument, INode, IEventTarget, IMarkupFormattable, IParentNode, IGlobalEventHandlers, IDocumentStyle, INonElementParentNode, IDisposable { public override IElement DocumentElement => RootElement; public ISvgSvgElement RootElement => this.FindChild<ISvgSvgElement>(); internal SvgDocument(IBrowsingContext context, TextSource source) : base(context ?? BrowsingContext.New(null), source) { base.ContentType = MimeTypeNames.Svg; } internal SvgDocument(IBrowsingContext context = null) : this(context, new TextSource(string.Empty)) { } public override INode Clone(bool deep = true) { SvgDocument svgDocument = new SvgDocument(base.Context, new TextSource(base.Source.Text)); CloneDocument(svgDocument, deep); return svgDocument; } internal static async Task<IDocument> LoadAsync(IBrowsingContext context, CreateDocumentOptions options, CancellationToken cancelToken) { XmlParserOptions options2 = default(XmlParserOptions); SvgDocument document = new SvgDocument(context, options.Source); IElementFactory<SvgElement> factory = context.Configuration.GetFactory<IElementFactory<SvgElement>>(); SvgDocument document2 = document; IElementFactory<SvgElement> elementFactory = factory; XmlDomBuilder xmlDomBuilder = new XmlDomBuilder(document2, elementFactory.Create); document.Setup(options); context.NavigateTo(document); context.Fire(new HtmlParseEvent(document, false)); await xmlDomBuilder.ParseAsync(options2, cancelToken).ConfigureAwait(false); context.Fire(new HtmlParseEvent(document, true)); return document; } protected override string GetTitle() { ISvgTitleElement svgTitleElement = RootElement.FindChild<ISvgTitleElement>(); return ((svgTitleElement != null) ? svgTitleElement.TextContent.CollapseAndStrip() : null) ?? base.GetTitle(); } protected override void SetTitle(string value) { ISvgTitleElement svgTitleElement = RootElement.FindChild<ISvgTitleElement>(); if (svgTitleElement == null) { svgTitleElement = new SvgTitleElement(this, null); RootElement.AppendChild(svgTitleElement); } svgTitleElement.TextContent = value; } } }