Parse() public method

Parses the specified XML node.
public Parse ( XmlNode xmlNode ) : GoogleSiteSearchParserResult
xmlNode System.Xml.XmlNode The XML node.
return GoogleSiteSearchParserResult
コード例 #1
0
        /// <summary>
        /// Parses the result.
        /// </summary>
        /// <param name="data">The data.</param>
        /// <returns></returns>
        protected virtual GoogleSiteSearchParserResult ParseResult(string data)
        {
            XmlDocument xmlDocument = new XmlDocument();

            // Load the result into a friendly structure
            try
            {
                xmlDocument.LoadXml(data);
            }
            catch (XmlException xmlException)
            {
                log.Error("An error occured while loading the Google SiteSearch XML.", xmlException);
            }

            // Parse the result
            try
            {
                GoogleSiteSearchParserResult result;
                using (GoogleSiteSearchParser googleSiteSearchParser = new GoogleSiteSearchParser())
                {
                    result = googleSiteSearchParser.Parse(xmlDocument.SelectSingleNode("GSP"));
                }

                return(result);
            }
            catch (XPathException xPathException)
            {
                log.Error("An error occured while parsing the Google SiteSearch XML response.", xPathException);
            }

            return(null);
        }
コード例 #2
0
        /// <summary>
        /// Parses the result.
        /// </summary>
        /// <param name="data">The data.</param>
        /// <returns></returns>
        protected virtual GoogleSiteSearchParserResult ParseResult(string data)
        {
            XmlDocument xmlDocument = new XmlDocument();

            // Load the result into a friendly structure
            try
            {
                xmlDocument.LoadXml(data);
            }
            catch (XmlException xmlException)
            {
                log.Error("An error occured while loading the Google SiteSearch XML.", xmlException);
            }

            // Parse the result
            try
            {
                GoogleSiteSearchParserResult result;
                using (GoogleSiteSearchParser googleSiteSearchParser = new GoogleSiteSearchParser())
                {
                    result = googleSiteSearchParser.Parse(xmlDocument.SelectSingleNode("GSP"));
                }

                return result;
            }
            catch (XPathException xPathException)
            {
                log.Error("An error occured while parsing the Google SiteSearch XML response.", xPathException);
            }

            return null;
        }