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); }
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); }
public TextElements FindByXPathPar(XPathPar xpar, TextElements senderitems = null) { var elements = new TextElements(); elements = this.FindByXPathByBlockContainer(xpar.XPathBlockList, senderitems); if (xpar.XPathExpressions.Count > 0 && elements.Count > 0) { elements.SortItems(); for (int j = 0; j < xpar.XPathExpressions.Count; j++) { var exp = xpar.XPathExpressions[j]; elements = XPathActions.Eliminate(elements, exp); if (elements.Count == 0) { break; } } } return(elements); }