public bool Any(Func <XPathHandler, XPathHandler> xpath) { XPathHandler xpathHandler = new XPathHandler(); var node = this._currentNode; if (xpath != null) { node = node.SelectSingleNode(xpath(xpathHandler).GetPath()); } if (node != null) { return(HtmlHandler.GetImplement(_logPrefix, node) != null); } return(false); }
public string GetFromAttribute(Func <XPathHandler, XPathHandler> xpath, string attribute, Func <string, string> strHandler) { XPathHandler xpathHandler = new XPathHandler(); var node = this._currentNode; if (xpath != null) { node = node.SelectSingleNode(xpath(xpathHandler).GetPath()); } if (node != null && node.Attributes.Contains(attribute)) { return(this.StrHandle(strHandler, node.Attributes[attribute].Value)); } return(null); }
public IDictionary <int, string> Gets(Func <XPathHandler, XPathHandler> xpath, Func <string, string> strHandler) { XPathHandler xpathHandler = new XPathHandler(); var node = this._currentNode; var nodes = node.ChildNodes; if (xpath != null) { nodes = node.SelectNodes(xpath(xpathHandler).GetPath()); } if (nodes != null && nodes.Count > 0) { return((from a in nodes select this.StrHandle(strHandler, HtmlHandler.GetImplement(_logPrefix, a).InnerHtml)) .Select((value, index) => new { value, index }) .ToDictionary(a => a.index, a => a.value)); } return(null); }
public T Get <T>(Func <XPathHandler, XPathHandler> xpath, Func <string, string> strHandler) { XPathHandler xpathHandler = new XPathHandler(); var node = this._currentNode; if (xpath != null) { node = node.SelectSingleNode(xpath(xpathHandler).GetPath()); } if (node != null) { var result = this.StrHandle(strHandler, HtmlHandler.GetImplement(_logPrefix, node).InnerHtml).Trim(); if (!string.IsNullOrEmpty(result)) { return((T)Convert.ChangeType(result, typeof(T)));; } } return(default(T)); }
public IDictionary <int, string> GetsFromAttribute(Func <XPathHandler, XPathHandler> xpath, string attribute, Func <string, string> strHandler) { XPathHandler xpathHandler = new XPathHandler(); var node = this._currentNode; var nodes = node.ChildNodes; if (xpath != null) { nodes = node.SelectNodes(xpath(xpathHandler).GetPath()); } if (nodes != null && nodes.Count > 0) { return((from a in nodes where a.Attributes.Contains(attribute) select this.StrHandle(strHandler, a.Attributes[attribute].Value)) .Select((value, index) => new { value, index }) .ToDictionary(a => a.index, a => a.value)); } return(null); }
public IDictionary <int, Dictionary <string, string> > GetsAttributes(Func <XPathHandler, XPathHandler> xpath, Func <string, string> strHandler) { XPathHandler xpathHandler = new XPathHandler(); var node = this._currentNode; var nodes = node.ChildNodes; if (xpath != null) { nodes = node.SelectNodes(xpath(xpathHandler).GetPath()); } if (nodes != null && nodes.Count > 0) { return(nodes.Select((value, index) => new { value, index }).ToDictionary(x => x.index, x => x.value.Attributes.Select((value, index) => new { value.Name, value.Value }).ToDictionary(y => y.Name, y => y.Value))); } return(null); }