public override void CollectInto(NodeList collectionList, string filter)
 {
     if (filter == REMARK_NODE_FILTER)
     {
         collectionList.Add(this);
     }
 }
Beispiel #2
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);
        }
 /// <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);
     }
 }
 /// <summary> Constructor takes in tagData, compositeTagData
 /// </summary>
 /// <param name="">tagData
 /// </param>
 /// <param name="">compositeTagData
 ///
 /// </param>
 public FormTag(TagData tagData, CompositeTagData compositeTagData) : base(tagData, compositeTagData)
 {
     this.formURL       = compositeTagData.StartTag["ACTION"];
     this.formName      = compositeTagData.StartTag["NAME"];
     this.formMethod    = compositeTagData.StartTag["METHOD"];
     this.formInputList = compositeTagData.Children.SearchFor(typeof(InputTag));
 }
Beispiel #5
0
 public override void CollectInto(NodeList collectionList, Type nodeType)
 {
     base.CollectInto(collectionList, nodeType);
     foreach (Node node in this)
     {
         node.CollectInto(collectionList, nodeType);
     }
 }
Beispiel #6
0
 public override void CollectInto(NodeList collectionList, string filter)
 {
     base.CollectInto(collectionList, filter);
     foreach (Node node in this)
     {
         node.CollectInto(collectionList, filter);
     }
 }
Beispiel #7
0
 public CompositeTagData(Tag startTag, Tag endTag, NodeList children)
 {
     this.startTag = startTag;
     this.endTag   = endTag;
     this.children = new NodeList();
     if (children != null)
     {
         foreach (Node child in children)
         {
             this.children.Add(child);
         }
     }
 }
Beispiel #8
0
 public CompositeTagScannerHelper(CompositeTagScanner scanner, Tag tag, string url, NodeReader reader,
                                  string currLine, bool balance_quotes)
 {
     this.scanner        = scanner;
     this.tag            = tag;
     this.url            = url;
     this.reader         = reader;
     this.currLine       = currLine;
     this.endTag         = null;
     this.nodeList       = new NodeList();
     this.endTagFound    = false;
     this.balance_quotes = balance_quotes;
 }
        public void Scan()
        {
            CreateParser("<html>" + "	<head>"+ "		<title>Some Title</title>"+ "	</head>"+ "	<body>" + "		Some data"+
                         "	</body>"+ "</html>");
            parser.AddScanner(new TitleScanner(""));
            parser.AddScanner(new HtmlScanner());
            ParseAndAssertNodeCount(1);
            AssertType("html tag", typeof(Html), this.node[0]);
            Html     html     = (Html)this.node[0];
            NodeList nodeList = new NodeList();

            html.CollectInto(nodeList, typeof(TitleTag));
            Assert.AreEqual(1, nodeList.Size, "nodelist size");
            Node node = nodeList[0];

            AssertType("expected title tag", typeof(TitleTag), node);
            TitleTag titleTag = (TitleTag)node;

            AssertStringEquals("title", "Some Title", titleTag.Title);
        }
Beispiel #10
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);
        }
Beispiel #11
0
 public CompositeTag(TagData tagData, CompositeTagData compositeTagData) : base(tagData)
 {
     this.childTags = compositeTagData.Children;
     this.startTag  = compositeTagData.StartTag;
     this.endTag    = compositeTagData.EndTag;
 }