Example #1
0
        /// <summary>
        /// Parses the given source and creates the document.
        /// </summary>
        /// <param name="options">The options to use for parsing.</param>
        public Document Parse(XmlParserOptions options)
        {
            var token = default(XmlToken);

            do
            {
                token = _tokenizer.Get();
                Consume(token);
            }while (token.Type != XmlTokenType.EndOfFile);

            return(_document);
        }
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;
 }
Example #3
0
        /// <summary>
        /// Parses the given source and creates the document.
        /// </summary>
        /// <param name="options">The options to use for parsing.</param>
        public Document Parse(XmlParserOptions options)
        {
            var token = default(XmlToken);

            _options = options;
            _tokenizer.IsSuppressingErrors = options.IsSuppressingErrors;

            do
            {
                token = _tokenizer.Get();
                Consume(token);
            }while (token.Type != XmlTokenType.EndOfFile);

            return(_document);
        }
Example #4
0
        /// <summary>
        /// Parses the given source asynchronously and creates the document.
        /// </summary>
        /// <param name="options">The options to use for parsing.</param>
        /// <param name="cancelToken">The cancellation token to use.</param>
        public async Task<Document> ParseAsync(XmlParserOptions options, CancellationToken cancelToken)
        {
            var source = _document.Source;
            var token = default(XmlToken);

            do
            {
                if (source.Length - source.Index < 1024)
                    await source.Prefetch(8192, cancelToken).ConfigureAwait(false);

                token = _tokenizer.Get();
                Consume(token);
            }
            while (token.Type != XmlTokenType.EndOfFile);

            return _document;
        }
Example #5
0
        /// <summary>
        /// Parses the given source asynchronously and creates the document.
        /// </summary>
        /// <param name="options">The options to use for parsing.</param>
        /// <param name="cancelToken">The cancellation token to use.</param>
        public async Task <Document> ParseAsync(XmlParserOptions options, CancellationToken cancelToken)
        {
            var source = _document.Source;
            var token  = default(XmlToken);

            _options = options;

            do
            {
                if (source.Length - source.Index < 1024)
                {
                    await source.Prefetch(8192, cancelToken).ConfigureAwait(false);
                }

                token = _tokenizer.Get();
                Consume(token);
            }while (token.Type != XmlTokenType.EndOfFile);

            return(_document);
        }
Example #6
0
        /// <summary>
        /// Parses the given source and creates the document.
        /// </summary>
        /// <param name="options">The options to use for parsing.</param>
        public Document Parse(XmlParserOptions options)
        {
            var token = default(XmlToken);

            do
            {
                token = _tokenizer.Get();
                Consume(token);
            }
            while (token.Type != XmlTokenType.EndOfFile);

            return _document;
        }
Example #7
0
 /// <summary>
 /// Creates a new parser with the custom options and the given context.
 /// </summary>
 /// <param name="options">The options to use.</param>
 /// <param name="context">The context to use.</param>
 public XmlParser(XmlParserOptions options, IBrowsingContext context)
 {
     _options = options;
     _context = context;
 }
Example #8
0
 /// <summary>
 /// Creates a new parser with the custom options and configuration.
 /// </summary>
 /// <param name="options">The options to use.</param>
 /// <param name="configuration">The configuration to use.</param>
 public XmlParser(XmlParserOptions options, IConfiguration configuration)
     : this(options, BrowsingContext.New(configuration))
 {
 }
Example #9
0
 /// <summary>
 /// Creates a new parser with the custom options.
 /// </summary>
 /// <param name="options">The options to use.</param>
 public XmlParser(XmlParserOptions options)
     : this(options, Configuration.Default)
 {
 }
Example #10
0
        /// <summary>
        /// Parses the given source and creates the document.
        /// </summary>
        /// <param name="options">The options to use for parsing.</param>
        public Document Parse(XmlParserOptions options)
        {
            var token = default(XmlToken);
            _options = options;
            _tokenizer.IsSuppressingErrors = options.IsSuppressingErrors;

            do
            {
                token = _tokenizer.Get();
                Consume(token);
            }
            while (token.Type != XmlTokenType.EndOfFile);

            return _document;
        }
Example #11
0
 /// <summary>
 /// Creates a new parser with the custom options and the given context.
 /// </summary>
 /// <param name="options">The options to use.</param>
 /// <param name="context">The context to use.</param>
 public XmlParser(XmlParserOptions options, IBrowsingContext context)
 {
     _options = options;
     _context = context;
 }
Example #12
0
 /// <summary>
 /// Creates a new parser with the custom options and configuration.
 /// </summary>
 /// <param name="options">The options to use.</param>
 /// <param name="configuration">The configuration to use.</param>
 public XmlParser(XmlParserOptions options, IConfiguration configuration)
     : this(options, BrowsingContext.New(configuration))
 {
 }
Example #13
0
 /// <summary>
 /// Creates a new parser with the custom options.
 /// </summary>
 /// <param name="options">The options to use.</param>
 public XmlParser(XmlParserOptions options)
     : this(options, Configuration.Default)
 {
 }