Example #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);
 }
Example #2
0
        public TextElements GetElementsByPath(List <XPathBlock> block)
        {
            TextElements elements = new TextElements();

            for (int i = 0; i < this.SubElementsCount; i++)
            {
                var subelem = this.SubElements[i];
                if (subelem.ElementType != TextElementType.ElementNode)
                {
                    continue;
                }
                for (int j = 0; j < block.Count; j++)
                {
                    var curblock = block[j];
                    if (curblock.IsAttributeSelector)
                    {
                        if (curblock.BlockName == "*")
                        {
                            if (subelem.ElemAttr.Count == 0)
                            {
                                continue;
                            }
                        }
                        else
                        {
                            if (!subelem.ElemAttr.HasAttribute(curblock.BlockName))
                            {
                                continue;
                            }
                        }
                    }
                    else
                    {
                        if (curblock.BlockName != "*" && curblock.BlockName != subelem.ElemName)
                        {
                            continue;
                        }
                    }
                    if (elements.Contains(subelem) || (curblock.XPathExpressions.Count == 0 || XPathActions.XExpressionSuccess(subelem, curblock.XPathExpressions)))
                    {
                        elements.Add(subelem);
                        XPathActions.Eliminate(elements, curblock);
                    }
                    break;
                }
            }


            return(elements);
        }