Beispiel #1
0
        /// <summary> Finds a string node, however embedded it might be, and returns
        /// it. The string node will retain links to its parents, so
        /// further navigation is possible.
        /// </summary>
        /// <param name="">searchText
        /// </param>
        /// <returns> The list of string nodes (recursively) found.
        ///
        /// </returns>
        public virtual StringNode[] DigupStringNode(string searchText)
        {
            NodeList nodeList    = SearchFor(searchText);
            NodeList stringNodes = new NodeList();

            for (int i = 0; i < nodeList.Size; i++)
            {
                Node node = nodeList[i];
                if (node is StringNode)
                {
                    stringNodes.Add(node);
                }
                else
                {
                    if (node is CompositeTag)
                    {
                        CompositeTag ctag  = (CompositeTag)node;
                        StringNode[] nodes = ctag.DigupStringNode(searchText);
                        foreach (Node nestedNode in nodes)
                        {
                            stringNodes.Add(nestedNode);
                        }
                    }
                }
            }
            StringNode[] stringNode = new StringNode[stringNodes.Size];
            for (int i = 0; i < stringNode.Length; i++)
            {
                stringNode[i] = (StringNode)stringNodes[i];
            }
            return(stringNode);
        }
 public override void CollectInto(NodeList collectionList, string filter)
 {
     if (filter == REMARK_NODE_FILTER)
     {
         collectionList.Add(this);
     }
 }
 /// <summary> This method verifies that the current tag matches the provided
 /// filter. The match is based on the string object and not its contents,
 /// so ensure that you are using static final filter strings provided
 /// in the tag classes.
 /// </summary>
 /// <seealso cref="">String)
 ///
 /// </seealso>
 public override void CollectInto(NodeList collectionList, string filter)
 {
     if (thisScanner != null && thisScanner.Filter == filter)
     {
         collectionList.Add(this);
     }
 }
Beispiel #4
0
 private void DoChildAndEndTagCheckOn(Node currentNode)
 {
     if (currentNode is EndTag)
     {
         EndTag possibleEndTag = (EndTag)currentNode;
         if (IsExpectedEndTag(possibleEndTag))
         {
             endTagFound = true;
             endTag      = possibleEndTag;
             return;
         }
     }
     nodeList.Add(currentNode);
     scanner.ChildNodeEncountered(currentNode);
 }
Beispiel #5
0
        /// <summary> Searches for any node whose text representation contains the search
        /// string. Collects all such nodes in a NodeList.
        /// e.g. if you wish to find any textareas in a form tag containing "hello
        /// world", the code would be :
        /// <code>
        /// NodeList nodeList = formTag.SearchFor("Hello World");
        /// </code>
        /// </summary>
        /// <param name="searchString">search criterion
        /// </param>
        /// <param name="caseSensitive">specify whether this search should be case
        /// sensitive
        /// </param>
        /// <returns> NodeList Collection of nodes whose string contents or
        /// representation have the searchString in them
        ///
        /// </returns>
        public virtual NodeList SearchFor(string searchString, bool caseSensitive)
        {
            NodeList foundList = new NodeList();

            if (!caseSensitive)
            {
                searchString = searchString.ToUpper();
            }
            foreach (Node node in this)
            {
                string nodeTextString = node.ToPlainTextString();
                if (!caseSensitive)
                {
                    nodeTextString = nodeTextString.ToUpper();
                }
                if (nodeTextString.IndexOf(searchString) != -1)
                {
                    foundList.Add(node);
                }
            }
            return(foundList);
        }