예제 #1
0
 public bool XPathSuccessSingle(XPathBlock block)
 {
     if (this.ElementType != TextElementType.ElementNode || (block.BlockName != "*" && block.BlockName != this.ElemName))
     {
         return(false);
     }
     if (block.XPathExpressions.Count > 0)
     {
         int myIndex = this.Index;
         for (int i = 0; i < block.XPathExpressions.Count; i++)
         {
             if (!XPathActions.XExpressionSuccess(this, block.XPathExpressions[i], null, myIndex))
             {
                 return(false);
             }
         }
     }
     return(true);
 }
예제 #2
0
        public TextElements FindByXPath(XPathBlock xblock)
        {
            TextElements elements = new TextElements();

            for (int j = 0; j < this.Count; j++)
            {
                var elem      = this[j];
                var nextelems = elem.FindByXPath(xblock);
                for (int k = 0; k < nextelems.Count; k++)
                {
                    if (elements.Contains(nextelems[k]))
                    {
                        continue;
                    }
                    elements.Add(nextelems[k]);
                }
            }
            return(elements);
        }
예제 #3
0
        public TextElements FindByXPath(XPathBlock block)
        {
            TextElements foundedElems = new TextElements();

            if (block.IsAttributeSelector)
            {
                foundedElems = this.GetElementsHasAttributes(block.BlockName, block.BlockType == XPathBlockType.XPathBlockScanAllElem);
            }
            else
            {
                if (!string.IsNullOrEmpty(block.BlockName))
                {
                    if (block.BlockName == ".")
                    {
                        foundedElems.Add(this);
                        return(foundedElems);
                    }
                    else if (block.BlockName == "..")
                    {
                        foundedElems.Add(this.Parent);
                        return(foundedElems);
                    }
                    else
                    {
                        foundedElems = this.GetElementsByTagName(block.BlockName, block.BlockType == XPathBlockType.XPathBlockScanAllElem);
                    }
                }
            }
            if (block.XPathExpressions.Count > 0 && foundedElems.Count > 0)
            {
                for (int i = 0; i < block.XPathExpressions.Count; i++)
                {
                    var exp = block.XPathExpressions[i];
                    foundedElems = XPathActions.Eliminate(foundedElems, exp);
                    if (foundedElems.Count == 0)
                    {
                        break;
                    }
                }
            }
            return(foundedElems);
        }