Exemplo n.º 1
0
        public TableEntity(IHtmlElement tableElement)
        {
            var head = tableElement.FindFirst("thead");
            this.THead = new THeadEntity(head);

            var headTrList = head.Find("tr");
            foreach (var tr in headTrList)
            {
                var trEntity = new TrEntity(tr);
                var tdList = tr.Find("td").ToList();
                foreach (var td in tdList)
                {
                    trEntity.TdList.Add(new TdEntity(td) { Text = td.InnerText() });
                }
                this.THead.TrList.Add(trEntity);
            }
            var body = tableElement.FindFirst("tbody");
            this.TBody = new TBodyEntity(body);

            var bodyTrList = body.Find("tr");
            foreach (var tr in bodyTrList)
            {
                var trEntity = new TrEntity(tr);
                var tdList = tr.Find("td").ToList();
                foreach (var td in tdList)
                {
                    trEntity.TdList.Add(new TdEntity(td) { Text = td.InnerText() });
                }
                this.TBody.TrList.Add(trEntity);
            }
        }
Exemplo n.º 2
0
        public TableEntity(IHtmlElement tableElement)
        {
            var head = tableElement.FindFirst("thead");

            this.THead = new THeadEntity(head);

            var headTrList = head.Find("tr");

            foreach (var tr in headTrList)
            {
                var trEntity = new TrEntity(tr);
                var tdList   = tr.Find("td").ToList();
                foreach (var td in tdList)
                {
                    trEntity.TdList.Add(new TdEntity(td)
                    {
                        Text = td.InnerText()
                    });
                }
                this.THead.TrList.Add(trEntity);
            }
            var body = tableElement.FindFirst("tbody");

            this.TBody = new TBodyEntity(body);

            var bodyTrList = body.Find("tr");

            foreach (var tr in bodyTrList)
            {
                var trEntity = new TrEntity(tr);
                var tdList   = tr.Find("td").ToList();
                foreach (var td in tdList)
                {
                    trEntity.TdList.Add(new TdEntity(td)
                    {
                        Text = td.InnerText()
                    });
                }
                this.TBody.TrList.Add(trEntity);
            }
        }