public static XmlDocument GoogleSiteSearchToXmlDocument(GoogleSiteSearch search, List<GoogleSiteSearchResult> results) { /* <Search> <NextResultPageUrl></NextResultPageUrl> <PreviousResultPageUrl></PreviousResultPageUrl> <NumberOfHits></NumberOfHits> <Results> <Result> <Description></Description> <Headline></Headline> <Language></Language> <Url></Url> </Result> <Results> </Search> */ XmlDocument doc = new XmlDocument(); doc.LoadXml("<Search/>"); XmlNode newNode = doc.CreateElement("NextResultPageUrl"); newNode.InnerText = search.NextResultPageUrl; doc.FirstChild.AppendChild(newNode); newNode = doc.CreateElement("PreviousResultPageUrl"); newNode.InnerText = search.PreviousResultPageUrl; doc.FirstChild.AppendChild(newNode); newNode = doc.CreateElement("NumberOfHits"); newNode.InnerText = search.NumberOfHits; doc.FirstChild.AppendChild(newNode); XmlNode resultsNode = doc.CreateElement("Results"); doc.FirstChild.AppendChild(resultsNode); foreach (GoogleSiteSearchResult searchResult in results) { XmlNode resultNode = doc.CreateElement("Result"); resultsNode.AppendChild(resultNode); newNode = doc.CreateElement("Description"); newNode.InnerText = searchResult.Description; resultNode.AppendChild(newNode); newNode = doc.CreateElement("Headline"); newNode.InnerText = searchResult.Headline; resultNode.AppendChild(newNode); newNode = doc.CreateElement("Language"); newNode.InnerText = searchResult.Language; resultNode.AppendChild(newNode); newNode = doc.CreateElement("Url"); newNode.InnerText = searchResult.Url; resultNode.AppendChild(newNode); } return doc; }
public static XPathNodeIterator Search(string query, int pageSize, int pageNumber, string site) { GoogleSiteSearch search = new GoogleSiteSearch(query, site); List<GoogleSiteSearchResult> results = search.Search(pageNumber.ToString(), pageSize.ToString()); XmlDocument document = GoogleSiteSearchUtil.GoogleSiteSearchToXmlDocument(search, results); XPathNavigator navigator = document.FirstChild.CreateNavigator(); return navigator.Select("/"); }
public static XPathNodeIterator Search(string query, int pageSize, int pageNumber, string site) { GoogleSiteSearch search = new GoogleSiteSearch(query, site); List <GoogleSiteSearchResult> results = search.Search(pageNumber.ToString(), pageSize.ToString()); XmlDocument document = GoogleSiteSearchUtil.GoogleSiteSearchToXmlDocument(search, results); XPathNavigator navigator = document.FirstChild.CreateNavigator(); return(navigator.Select("/")); }
public void Serach() { GoogleSiteSearch search = new GoogleSiteSearch("UNEP"); List<GoogleSiteSearchResult> results = search.Search("2", "15"); GoogleSiteSearch search2 = new GoogleSiteSearch("UNEP", "www.latincarbon.com"); List<GoogleSiteSearchResult> results2 = search2.Search("1", "20"); XPathNodeIterator iterator = GoogleSiteSearchXsltExtension.Search("UNEP", 10, 1, "www.latincarbon.com"); }
public static XmlDocument GoogleSiteSearchToXmlDocument(GoogleSiteSearch search, List <GoogleSiteSearchResult> results) { /* * <Search> * <NextResultPageUrl></NextResultPageUrl> * <PreviousResultPageUrl></PreviousResultPageUrl> * <NumberOfHits></NumberOfHits> * <Results> * <Result> * <Description></Description> * <Headline></Headline> * <Language></Language> * <Url></Url> * </Result> * <Results> * </Search> */ XmlDocument doc = new XmlDocument(); doc.LoadXml("<Search/>"); XmlNode newNode = doc.CreateElement("NextResultPageUrl"); newNode.InnerText = search.NextResultPageUrl; doc.FirstChild.AppendChild(newNode); newNode = doc.CreateElement("PreviousResultPageUrl"); newNode.InnerText = search.PreviousResultPageUrl; doc.FirstChild.AppendChild(newNode); newNode = doc.CreateElement("NumberOfHits"); newNode.InnerText = search.NumberOfHits; doc.FirstChild.AppendChild(newNode); XmlNode resultsNode = doc.CreateElement("Results"); doc.FirstChild.AppendChild(resultsNode); foreach (GoogleSiteSearchResult searchResult in results) { XmlNode resultNode = doc.CreateElement("Result"); resultsNode.AppendChild(resultNode); newNode = doc.CreateElement("Description"); newNode.InnerText = searchResult.Description; resultNode.AppendChild(newNode); newNode = doc.CreateElement("Headline"); newNode.InnerText = searchResult.Headline; resultNode.AppendChild(newNode); newNode = doc.CreateElement("Language"); newNode.InnerText = searchResult.Language; resultNode.AppendChild(newNode); newNode = doc.CreateElement("Url"); newNode.InnerText = searchResult.Url; resultNode.AppendChild(newNode); } return(doc); }