Example #1
0
        public TextElements GetElementsHasAttributes(string name, bool depthscan = false, int limit = 0)
        {
            var elements = new TextElements();
            var lower    = name.ToLower();

            for (int i = 0; i < this.subElements.Count; i++)
            {
                var elem = this.subElements[i];
                if (elem.ElemAttr.Count > 0 && lower == "*")
                {
                    elements.Add(elem);
                }
                else
                {
                    if (elem.ElemAttr.HasAttribute(lower))
                    {
                        elements.Add(elem);
                    }
                }

                if (depthscan && elem.SubElementsCount > 0)
                {
                    elements.AddRange(elem.GetElementsHasAttributes(name, depthscan));
                }
            }
            return(elements);
        }
Example #2
0
        private TextElements FindByXPathByBlockContainer(XPathBlockContainer container, TextElements senderitems = null)
        {
            var  elements = new TextElements();
            bool inor     = true;

            for (int i = 0; i < container.Count; i++)
            {
                var curblocks = container[i];
                if (curblocks.IsOr())
                {
                    inor = true;
                    continue;
                }
                if (!inor)
                {
                    if (curblocks.IsBlocks())
                    {
                        elements = this.FindByXPathBlockList(curblocks as XPathBlocks, elements);
                    }
                    else
                    {
                        elements.AddRange(this.FindByXPathPar(curblocks as XPathPar, senderitems));
                    }
                }
                else
                {
                    if (curblocks.IsBlocks())
                    {
                        elements.AddRange(this.FindByXPathBlockList(curblocks as XPathBlocks));
                    }
                    else
                    {
                        elements.AddRange(this.FindByXPathPar(curblocks as XPathPar));
                    }
                }

                inor = false;
            }

            return(elements);
        }
Example #3
0
        public TextElements GetElementsByTagName(string name, bool depthscan = false, int limit = 0)
        {
            var elements = new TextElements();
            var lower    = name.ToLower();

            for (int i = 0; i < this.subElements.Count; i++)
            {
                var elem = this.subElements[i];
                if (elem.ElemName.ToLower() == lower || lower == "*")
                {
                    elements.Add(elem);
                    if (limit > 0 && elements.Count >= limit)
                    {
                        break;
                    }
                }
                if (depthscan && elem.SubElementsCount > 0)
                {
                    elements.AddRange(elem.GetElementsByTagName(name, depthscan));
                }
            }
            return(elements);
        }