Example #1
0
 public override INode Clone(Boolean deep = true)
 {
     var node = new XmlDocument(Context, new TextSource(Source.Text));
     CopyProperties(this, node, deep);
     CopyDocumentProperties(this, node, deep);
     return node;
 }
Example #2
0
 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;
 }
 /// <summary>
 /// Loads the document in the provided context from the given response.
 /// </summary>
 /// <param name="context">The browsing context.</param>
 /// <param name="response">The response to consider.</param>
 /// <param name="source">The source to use.</param>
 /// <param name="cancelToken">Token for cancellation.</param>
 /// <returns>The task that builds the document.</returns>
 internal async static Task<XmlDocument> LoadAsync(IBrowsingContext context, IResponse response, TextSource source, CancellationToken cancelToken)
 {
     var contentType = response.Headers.GetOrDefault(HeaderNames.ContentType, MimeTypes.Xml);
     var document = new XmlDocument(context, source);
     var parser = new XmlDomBuilder(document);
     document.ContentType = contentType;
     document.Referrer = response.Headers.GetOrDefault(HeaderNames.Referer, String.Empty);
     document.DocumentUri = response.Address.Href;
     document.Cookie = response.Headers.GetOrDefault(HeaderNames.SetCookie, String.Empty);
     document.ReadyState = DocumentReadyState.Loading;
     await parser.ParseAsync(default(XmlParserOptions), cancelToken).ConfigureAwait(false);
     return document;
 }
Example #4
0
        /// <summary>
        /// Loads the document in the provided context from the given response.
        /// </summary>
        /// <param name="context">The browsing context.</param>
        /// <param name="options">The creation options to consider.</param>
        /// <param name="cancelToken">Token for cancellation.</param>
        /// <returns>The task that builds the document.</returns>
        internal async static Task<IDocument> LoadAsync(IBrowsingContext context, CreateDocumentOptions options, CancellationToken cancelToken)
        {
            var document = new XmlDocument(context, options.Source);
            var evt = new HtmlParseStartEvent(document);
            var events = context.Configuration.Events;
            var parser = new XmlDomBuilder(document);
            document.Setup(options);
            context.NavigateTo(document);

            if (events != null)
                events.Publish(evt);

            await parser.ParseAsync(default(XmlParserOptions), cancelToken).ConfigureAwait(false);
            evt.FireEnd();
            return document;
        }
Example #5
0
        /// <summary>
        /// Loads the document in the provided context from the given response.
        /// </summary>
        /// <param name="context">The browsing context.</param>
        /// <param name="response">The response to consider.</param>
        /// <param name="source">The source to use.</param>
        /// <param name="cancelToken">Token for cancellation.</param>
        /// <returns>The task that builds the document.</returns>
        internal async static Task<XmlDocument> LoadAsync(IBrowsingContext context, IResponse response, TextSource source, CancellationToken cancelToken)
        {
            var document = new XmlDocument(context, source);
            var evt = new HtmlParseStartEvent(document);
            var events = context.Configuration.Events;
            var parser = new XmlDomBuilder(document);
            document.ContentType = response.Headers.GetOrDefault(HeaderNames.ContentType, MimeTypes.Xml);
            document.Referrer = response.Headers.GetOrDefault(HeaderNames.Referer, String.Empty);
            document.DocumentUri = response.Address.Href;
            document.Cookie = response.Headers.GetOrDefault(HeaderNames.SetCookie, String.Empty);
            document.ReadyState = DocumentReadyState.Loading;
            context.NavigateTo(document);

            if (events != null)
                events.Publish(evt);

            await parser.ParseAsync(default(XmlParserOptions), cancelToken).ConfigureAwait(false);
            evt.FireEnd();
            return document;
        }
Example #6
0
        public IXmlDocument CreateDocument(String namespaceUri = null, String qualifiedName = null, IDocumentType doctype = null)
        {
            var document = new XmlDocument();

            if (doctype != null)
            {
                document.AppendChild(doctype);
            }

            if (!String.IsNullOrEmpty(qualifiedName))
            {
                var element = document.CreateElement(namespaceUri, qualifiedName);

                if (element != null)
                {
                    document.AppendChild(element);
                }
            }

            document.BaseUrl = _owner.BaseUrl;
            return document;
        }
Example #7
0
 public override INode Clone(Boolean deep = true)
 {
     var node = new XmlDocument(Context, new TextSource(Source.Text));
     CloneDocument(node, deep);
     return node;
 }
Example #8
0
 XmlDocument CreateDocument(TextSource textSource)
 {
     var document = new XmlDocument(_context, textSource);
     return document;
 }