private static DataTable _Select(XNode node, string xpath, params string[] values) { if (node == null) { Trace.WriteLine("warning no xml"); _SetResult(null); return(null); } //if (XmlDocument == null) throw new HtmlXmlReaderException("error no xml data loaded"); //HtmlXmlTables t = null; //if (_nodePathWithTableCode) //{ // if (_htmlXmlTables == null) _htmlXmlTables = HtmlXml.GetTables(XmlDocument); // t = _htmlXmlTables; //} if (values.Length == 0) { values = new string[] { ":.:NodeValue" } } ; //XmlSelect select = pb.old.Xml.Select(node, new XmlSelectParameters(t, _url, _traceFunction), xpath, values); if (xpath == null) { Trace.WriteLine("warning no xpath"); return(null); } XmlSelect xmlSelect = new XmlSelect(); xmlSelect.SourceNode = node; xmlSelect.SelectPrm = new XmlSelectParameters(); xmlSelect.SourceXPathNode = xpath; xmlSelect.SourceXPathValues = values; //DataTable dt = pb.old.Xml.ReadSelect(select); DataTable dt = xmlSelect.zToDataTable(); Trace.WriteLine("found {0} elements", dt.Rows.Count); _SetResult(dt); return(dt); }
public static magazine3kPrint_01[] search(string url, bool detail = false) { List <magazine3kPrint_01> prints = new List <magazine3kPrint_01>(); ghxr.Load(url); while (true) { string urlNextPage = ghxr.SelectValue("//a[@class='pBtnSelected']/following-sibling::a/@href:.:EmptyRow"); XmlSelect select = ghxr.Select("//div[@class='res']", "@class", ".//a/@href:.:n(href)", ".//a//text():.:n(label1)", ".//span[1]//text():.:n(info1)", ".//span[2]//text():.:n(info2)", ".//span[3]//text():.:n(info3)", ".//span[4]//text():.:n(info4)", ".//img/@src:.:n(img)", ".//div[@class='justi']//text():.:n(label2):Concat()", ".//div[@class='cat']/text():.:n(category)"); while (select.Get()) { magazine3kPrint_01 print; if (!detail) { print = new magazine3kPrint_01(); print.url = (string)select["href"]; print.title = (string)select["label1"]; print.SetCategory((string)select["category"]); print.SetInfo1(new string[] { (string)select["info1"], (string)select["info2"], (string)select["info3"], (string)select["info4"] }); print.imageUrl = (string)select["img"]; print.SetInfo3((string)select["label2"]); } else { string urlDetail = (string)select["href"]; print = loadPrint(urlDetail); } prints.Add(print); } if (urlNextPage == null) { break; } ghxr.Load(urlNextPage); } return(prints.ToArray()); }
private static DataTable _Select(XNode node, string xpath, params string[] values) { if (node == null) { Trace.WriteLine("warning no xml"); _SetResult(null); return null; } //if (XmlDocument == null) throw new HtmlXmlReaderException("error no xml data loaded"); //HtmlXmlTables t = null; //if (_nodePathWithTableCode) //{ // if (_htmlXmlTables == null) _htmlXmlTables = HtmlXml.GetTables(XmlDocument); // t = _htmlXmlTables; //} if (values.Length == 0) values = new string[] { ":.:NodeValue" }; //XmlSelect select = pb.old.Xml.Select(node, new XmlSelectParameters(t, _url, _traceFunction), xpath, values); if (xpath == null) { Trace.WriteLine("warning no xpath"); return null; } XmlSelect xmlSelect = new XmlSelect(); xmlSelect.SourceNode = node; xmlSelect.SelectPrm = new XmlSelectParameters(); xmlSelect.SourceXPathNode = xpath; xmlSelect.SourceXPathValues = values; //DataTable dt = pb.old.Xml.ReadSelect(select); DataTable dt = xmlSelect.zToDataTable(); Trace.WriteLine("found {0} elements", dt.Rows.Count); _SetResult(dt); return dt; }
private static DataTable _Select(XNode node, string xpath, params string[] values) { if (node == null) { Trace.WriteLine("warning no xml"); //_SetResult(null); return(null); } if (values.Length == 0) { values = new string[] { ":.:NodeValue" } } ; //XmlSelect select = pb.old.Xml.Select(node, new XmlSelectParameters(t, _url, _traceFunction), xpath, values); if (xpath == null) { Trace.WriteLine("warning no xpath"); return(null); } XmlSelect xmlSelect = new XmlSelect(); xmlSelect.SourceNode = node; xmlSelect.SelectPrm = new XmlSelectParameters(); xmlSelect.SourceXPathNode = xpath; xmlSelect.SourceXPathValues = values; //DataTable dt = pb.old.Xml.ReadSelect(select); DataTable dt = xmlSelect.zToDataTable(); Trace.WriteLine("found {0} elements", dt.Rows.Count); _SetResult(dt); return(dt); }