Package org.htmlparser.util

Examples of org.htmlparser.util.NodeList


    public HtmlPage(Parser parser)
    {
        super(false);
        parser.registerScanners();
        parser.addScanner(new TableScanner(parser));
        nodesInBody = new NodeList();
        tables = new NodeList();
        bodyTagBegin = false;
    }
View Full Code Here


            endTags = new NodeList[tagsToBeFound.length];
            endTagCount = new int[tagsToBeFound.length];
        }
        for (int i = 0; i < tagsToBeFound.length; i++)
        {
            tags[i] = new NodeList();
            if (endTagCheck)
                endTags[i] = new NodeList();
        }
        this.count = new int[tagsToBeFound.length];
        this.endTagCheck = endTagCheck;
    }
View Full Code Here

     * representation have the searchString in them
     */

    public NodeList searchFor(String searchString, boolean caseSensitive)
    {
        NodeList foundList = new NodeList();
        Node node;
        if (!caseSensitive)
            searchString = searchString.toUpperCase();
        for (SimpleNodeIterator e = children(); e.hasMoreNodes();)
        {
            node = e.nextNode();
            String nodeTextString = node.toPlainTextString();
            if (!caseSensitive)
                nodeTextString = nodeTextString.toUpperCase();
            if (nodeTextString.indexOf(searchString) != -1)
            {
                foundList.add(node);
            }
        }
        return foundList;
    }
View Full Code Here

     * @param searchText
     * @return The list of string nodes (recursively) found.
     */
    public StringNode[] digupStringNode(String searchText)
    {
        NodeList nodeList = searchFor(searchText);
        NodeList stringNodes = new NodeList();
        for (int i = 0; i < nodeList.size(); i++)
        {
            Node node = nodeList.elementAt(i);
            if (node instanceof StringNode)
            {
                stringNodes.add(node);
            }
            else
            {
                if (node instanceof CompositeTag)
                {
                    CompositeTag ctag = (CompositeTag) node;
                    StringNode[] nodes = ctag.digupStringNode(searchText);
                    for (int j = 0; j < nodes.length; j++)
                        stringNodes.add(nodes[j]);
                }
            }
        }
        StringNode[] stringNode = new StringNode[stringNodes.size()];
        for (int i = 0; i < stringNode.length; i++)
        {
            stringNode[i] = (StringNode) stringNodes.elementAt(i);
        }
        return stringNode;
    }
View Full Code Here

                + "</ul>"
                + "</ul>");
        parser.registerScanners();
        parseAndAssertNodeCount(1);

        NodeList nestedBulletLists =
            ((CompositeTag) node[0]).searchFor(BulletList.class);
        assertEquals("bullets in first list", 2, nestedBulletLists.size());
        BulletList firstList = (BulletList) nestedBulletLists.elementAt(0);
        Bullet firstBullet = (Bullet) firstList.childAt(0);
        Node firstNodeInFirstBullet = firstBullet.childAt(0);
        assertType(
            "first child in bullet",
            StringNode.class,
View Full Code Here

        super(name);
    }

    protected void setUp()
    {
        nodeList = new NodeList();
    }
View Full Code Here

        verify(delegates[i], times(1)).errorOccured();
      }
    }
   
    private Assertion assertion() throws SyntaxError {
    NodeList headerColumns = new NodeList();
    headerColumns.add(new TableColumn());
    TableHeader tableHeader = new TableHeader();
    tableHeader.setChildren(headerColumns);
    NodeList rowColumns = new NodeList();
    rowColumns.add(new TableColumn());
    TableRow tableRow = new TableRow();
    tableRow.setChildren(rowColumns);
    NodeList rows = new NodeList();
    rows.add(tableHeader);
    rows.add(tableRow);
    TableTag tableTag = new TableTag();
    tableTag.setChildren(rows);
      List<Assertion> list = new QueryTable(new HtmlTable(tableTag), "id", new SlimTestContextImpl()).getAssertions();
      return list.get(0);
    }
View Full Code Here

        }
    }

    public Node[] extractAllNodesThatAre(Class nodeType) throws ParserException
    {
        NodeList nodeList = new NodeList();
        for (NodeIterator e = elements(); e.hasMoreNodes();)
        {
            e.nextNode().collectInto(nodeList, nodeType);
        }
        return nodeList.toNodeArray();
    }
View Full Code Here

            optionTags.add(node);
    }

    public void beforeScanningStarts()
    {
        optionTags = new NodeList();
    }
View Full Code Here

    int count = 0;
    try {
      Parser parser = new Parser();
      parser.setInputHTML(inputHTML);
      parser.setEncoding("UTF-8");   
      NodeList nl = parser.parse(null);
      NodeList trs = nl.extractAllNodesThatMatch(new TagNameFilter("tr"),true);
      String regex = "([a-z]+) *= *\"?((?:(?! [a-z]+ *=|/? *>|\").)+)";
        Pattern p = Pattern.compile(regex, Pattern.DOTALL);
        for(int i=0;i<trs.size();i++) {
          NodeList nodes = trs.elementAt(i).getChildren();
          NodeList tds  = nodes.extractAllNodesThatMatch(new TagNameFilter("td"),true);
          for(int j=0;j<tds.size();j++) {
            count++;
            String content = tds.elementAt(j).toHtml();
            Matcher fit =  p.matcher(content);
            if (fit.find()) {
              String[] attributes = fit.group(2).replace("'", "").split(";");
              Map<String,String> mapAtt = new HashMap<String, String>();
              if(attributes.length > 1){
View Full Code Here

TOP

Related Classes of org.htmlparser.util.NodeList

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.