/// <summary> Opens a connection using the given url.
        /// </summary>
        /// <param name="url">The url to open.
        /// </param>
        /// <param name="feedback">The object to use for messages or <code>null</code>.
        /// </param>
        /// <exception cref="">ParserException if an I/O exception occurs accessing the url.
        ///
        /// </exception>
        public static WebRequest OpenConnection(System.Uri url, ParserFeedback feedback)
        {
            WebRequest ret;

            try
            {
                ret = (WebRequest)WebRequest.Create(url);
            }
            catch (System.IO.IOException ioe)
            {
                string          msg = "HTMLParser.OpenConnection() : Error in opening a connection to " + url.ToString();
                ParserException ex  = new ParserException(msg, ioe);
                if (null != feedback)
                {
                    feedback.Error(msg, ex);
                }
                throw ex;
            }

            return(ret);
        }
        /// <summary> Opens a connection based on a given string.
        /// The string is either a file, in which case <code>file://localhost</code>
        /// is prepended to a canonical path derived from the string, or a url that
        /// begins with one of the known protocol strings, i.e. <code>http://</code>.
        /// Embedded spaces are silently converted to %20 sequences.
        /// </summary>
        /// <param name="resource">The name of a file or a url.
        /// </param>
        /// <param name="feedback">The object to use for messages or <code>null</code> for no feedback.
        /// </param>
        /// <exception cref=""> ParserException if the string is not a valid url or file.
        ///
        /// </exception>
        public static WebRequest OpenConnection(string resource, ParserFeedback feedback)
        {
            System.Uri url;
            WebRequest ret;

            try
            {
                url = SupportClass.CreateUri(LinkProcessor.FixSpaces(resource));
                ret = ParserHelper.OpenConnection(url, feedback);
            }
            catch (System.UriFormatException ufe)
            {
                string          msg = "HTMLParser.OpenConnection() : Error in opening a connection to " + resource;
                ParserException ex  = new ParserException(msg, ufe);
                if (null != feedback)
                {
                    feedback.Error(msg, ex);
                }
                throw ex;
            }

            return(ret);
        }