Lemon.Core.Discover.HtmlAttributeParse.Parse C# (CSharp) Method

Parse() public method

public Parse ( string content ) : IEnumerable
content string
return IEnumerable
        public IEnumerable<string> Parse(string content)
        {
            var result = new List<string>();

            var htmlDocument = new HtmlDocument();

            htmlDocument.LoadHtml(content);

            var nodes = htmlDocument.DocumentNode.SelectNodes(_xpath);

            if (nodes == null)
            {
                Console.WriteLine("No nodes found in the current content");

                return result;
            }

            foreach (HtmlNode node in nodes)
            {
                var link = node.GetAttributeValue(_attribute, "");

                if (!string.IsNullOrEmpty(link))
                {
                    result.Add(link);
                }
            }

            return result;
        }
    }

Usage Example

Exemplo n.º 1
0
        public IEnumerable<string> Find(string text)
        {
            var htmlAttributes = new HtmlAttributeParse(_setting.XPathAttributeMap.XPath, _setting.XPathAttributeMap.Attribute);

            var attributes = htmlAttributes.Parse(text);

            var findResult = new List<string>();

            foreach (var attribute in attributes)
            {
                if (IsMatch(attribute))
                {
                    findResult.Add(Transform(attribute));
                }
            }

            return findResult;
        }
All Usage Examples Of Lemon.Core.Discover.HtmlAttributeParse::Parse
HtmlAttributeParse