/// <inheritdoc /> public override IElement ParseSubtree(String html) { var context = ((IElement)this).Owner?.Context; var source = new TextSource(html); var document = new XmlDocument(context, source); var parser = new XmlDomBuilder(document); var options = new XmlParserOptions { IsSuppressingErrors = true, }; return(parser.ParseFragment(options, this).DocumentElement); }
internal async static Task <IDocument> LoadAsync(IBrowsingContext context, CreateDocumentOptions options, CancellationToken cancelToken) { var parserOptions = new XmlParserOptions { }; var document = new XmlDocument(context, options.Source); var parser = new XmlDomBuilder(document); document.Setup(options); context.NavigateTo(document); context.Fire(new HtmlParseEvent(document, completed: false)); await parser.ParseAsync(default(XmlParserOptions), cancelToken).ConfigureAwait(false); context.Fire(new HtmlParseEvent(document, completed: true)); return(document); }
internal async static Task <IDocument> LoadAsync(IBrowsingContext context, CreateDocumentOptions options, CancellationToken cancelToken) { var parserOptions = new XmlParserOptions { }; var document = new SvgDocument(context, options.Source); var factory = context.Configuration.GetFactory <IElementFactory <SvgElement> >(); document.Setup(options); context.NavigateTo(document); context.Fire(new HtmlParseEvent(document, completed: false)); using (var parser = new XmlDomBuilder(document, factory.Create)) { await parser.ParseAsync(parserOptions, cancelToken).ConfigureAwait(false); } context.Fire(new HtmlParseEvent(document, completed: true)); return(document); }
static IDocument ParseXml(String content) { var options = new XmlParserOptions { IsSuppressingErrors = true }; var xml = new XmlParser(); try { return(xml.Parse(content)); } catch (XmlParseException ex) { content = GetXmlErrorContent(ex, content); return(xml.Parse(content)); } }