/// <summary> /// Parses the specified XML node. /// </summary> /// <param name="xmlNode">The XML node.</param> /// <returns></returns> public virtual GoogleSiteSearchParserResult Parse(XmlNode xmlNode) { GoogleSiteSearchParserResult gssp = new GoogleSiteSearchParserResult(); XmlNode searchResult = GetNode(xmlNode, "RES"); if (searchResult == null || searchResult.ChildNodes.Count <= 0) { return gssp; } foreach (XmlNode r in searchResult.ChildNodes) { if (r.Name == "M") { gssp.Hits = r.InnerText; continue; } if (r.Name == "NB") { XmlNode next = GetNode(r, "NU"); XmlNode previous = GetNode(r, "PU"); if (next != null) { gssp.NextUrl = next.InnerText; } if (previous != null) { gssp.PreviousUrl = previous.InnerText; } continue; } if (r.Name == "R") { GoogleSiteSearchResult parsedResult = new GoogleSiteSearchResult() { Url = GetNode(r, "U").InnerText, Headline = GetNode(r, "T").InnerText, Description = GetNode(r, "S").InnerText, Language = GetNode(r, "LANG").InnerText }; gssp.Result.Add(parsedResult); } } return gssp; }
/// <summary> /// Parses the specified XML node. /// </summary> /// <param name="xmlNode">The XML node.</param> /// <returns></returns> public virtual GoogleSiteSearchParserResult Parse(XmlNode xmlNode) { GoogleSiteSearchParserResult gssp = new GoogleSiteSearchParserResult(); XmlNode searchResult = GetNode(xmlNode, "RES"); if (searchResult == null || searchResult.ChildNodes.Count <= 0) { return(gssp); } foreach (XmlNode r in searchResult.ChildNodes) { if (r.Name == "M") { gssp.Hits = r.InnerText; continue; } if (r.Name == "NB") { XmlNode next = GetNode(r, "NU"); XmlNode previous = GetNode(r, "PU"); if (next != null) { gssp.NextUrl = next.InnerText; } if (previous != null) { gssp.PreviousUrl = previous.InnerText; } continue; } if (r.Name == "R") { GoogleSiteSearchResult parsedResult = new GoogleSiteSearchResult() { Url = GetNode(r, "U").InnerText, Headline = GetNode(r, "T").InnerText, Description = GetNode(r, "S").InnerText, Language = GetNode(r, "LANG").InnerText }; gssp.Result.Add(parsedResult); } } return(gssp); }