Beispiel #1
0
        private List <UserColor> ReadAllXPathNode(HtmlDocument doc, string xpath)
        {
            List <UserColor> result = new List <UserColor>();

            HtmlNodeCollection hrefs = doc.DocumentNode.SelectNodes(xpath);

            if (hrefs == null)
            {
                return(null);
            }

            const string namePath  = @"h3/a[@target]";
            const string colorPath = @"div[@class='meta']/h4";
            const string UrlStart  = @"http://www.peise.net/";

            foreach (HtmlNode nodeA in hrefs)
            {
                var nameNode  = nodeA.SelectNodes(namePath).FirstOrDefault();
                var colornode = nodeA.SelectNodes(colorPath).FirstOrDefault();
                if (nameNode != null && colornode != null)
                {
                    var res = new UserColor()
                    {
                        Name = nameNode.InnerText.Trim(),
                        Url  = UrlStart + nameNode.Attributes["href"].Value.Trim(),
                    };
                    var Ref = colornode.InnerText;
                    if (Ref.StartsWith("HEX:"))
                    {
                        res.RGB = Ref.Substring(4, 6);
                    }

                    result.Add(res);
                }
                ;
            }

            return(result);
        }
Beispiel #2
0
        private List<UserColor> ReadAllXPathNode(HtmlDocument doc, string xpath)
        {
            List<UserColor> result = new List<UserColor>();

            HtmlNodeCollection hrefs = doc.DocumentNode.SelectNodes(xpath);
            if (hrefs == null)
            {
                return null;
            }

            const string namePath = @"h3/a[@target]";
            const string colorPath = @"div[@class='meta']/h4";
            const string UrlStart = @"http://www.peise.net/";

            foreach (HtmlNode nodeA in hrefs)
            {
                var nameNode = nodeA.SelectNodes(namePath).FirstOrDefault();
                var colornode = nodeA.SelectNodes(colorPath).FirstOrDefault();
                if (nameNode != null && colornode != null)
                {
                    var res = new UserColor()
                    {
                        Name = nameNode.InnerText.Trim(),
                        Url = UrlStart + nameNode.Attributes["href"].Value.Trim(),
                    };
                    var Ref = colornode.InnerText;
                    if (Ref.StartsWith("HEX:"))
                    {
                        res.RGB = Ref.Substring(4, 6);
                    }

                    result.Add(res);
                };
            }

            return result;
        }