public static ScrapTable SelectTableByClass(this GeckoDocument document, String classname, int index = 0) { ScrapTable ret = new ScrapTable(); GeckoElement element = document.GetElementsByClassName(classname)[index] as GeckoElement; var collection = element.GetElementsByTagName("TR"); foreach (var row in collection) { foreach (var col in row.ChildNodes) { if (!(col is GeckoHtmlElement)) { continue; } var buffer = col as GeckoHtmlElement; if ("TD".Equals(buffer.TagName) || "TH".Equals(buffer.TagName)) { //ret.Set(col.TextContent); //ret.Set((col as GeckoHtmlElement).OuterHtml); ret.Set(col as GeckoHtmlElement); } } ret.Next(); } return(ret); }
private static IEnumerable <GeckoElement> FindMatchingSpans(ConfigurableDictionaryNode selectedNode, GeckoElement parent, ConfigurableDictionaryNode topLevelNode, FdoCache cache) { var elements = new List <GeckoElement>(); var desiredClass = CssGenerator.GetClassAttributeForConfig(selectedNode); if (ConfiguredXHTMLGenerator.IsCollectionNode(selectedNode, cache)) { desiredClass = CssGenerator.GetClassAttributeForCollectionItem(selectedNode); } foreach (var span in parent.GetElementsByTagName("span")) { if (span.GetAttribute("class") != null && span.GetAttribute("class").Split(' ')[0] == desiredClass && DoesGeckoElementOriginateFromConfigNode(selectedNode, span, topLevelNode)) { elements.Add(span); } } return(elements); }
public static ScrapTable SelectTableById(this GeckoDocument document, String id) { ScrapTable ret = new ScrapTable(); GeckoElement element = document.GetElementById(id); var collection = element.GetElementsByTagName("TR"); foreach (var row in collection) { foreach (var col in row.ChildNodes) { if (!(col is GeckoHtmlElement)) { continue; } var buffer = col as GeckoHtmlElement; if ("TD".Equals(buffer.TagName) || "TH".Equals(buffer.TagName)) { ret.Set(col as GeckoHtmlElement); } } ret.Next(); } return(ret); }
public static String GetElementByTagNameToNodeValue(this GeckoElement element, String tag, int index = 0) { return(element.GetElementsByTagName(tag)[index].FirstChild.NodeValue); }
public static T GetElementByTagName <T>(this GeckoElement element, String tag, int index = 0) where T : GeckoElement { return(element.GetElementsByTagName(tag)[index] as T); }