Package org.htmlparser

Examples of org.htmlparser.Node


    parser.addScanner(new AnotherScanner(false));
    parseAndAssertNodeCount(1);
    assertType("root node",CustomTag.class, node[0]);
    CustomTag root = (CustomTag)node[0];
    assertNodeCount("child count",2,root.getChildrenAsNodeArray());
    Node child = root.childAt(0);
    assertType("child",CustomTag.class,child);
    CustomTag customChild = (CustomTag)child;
    assertNodeCount("grand child count",1,customChild.getChildrenAsNodeArray());
    Node grandchild = customChild.childAt(0);
    assertType("grandchild",AnotherTag.class,grandchild);
  }
View Full Code Here


            "http://www.yahoo.com");
        Node[] node = new Node[10];
        // Register the image scanner
        parser.addScanner(new ImageScanner("-i", new LinkProcessor()));
        int i = 0;
        Node thisNode;
        for (NodeIterator e = parser.elements(); e.hasMoreNodes();)
        {
            thisNode = (Node) e.nextNode();
            if (thisNode instanceof ImageTag)
                node[i++] = thisNode;
View Full Code Here

        //    parser.addScanner(new TableScanner(parser));
        parseAndAssertNodeCount(2);
        assertType("first node type", TableRow.class, node[0]);
        TableRow row = (TableRow) node[0];
        TableColumn col = row.getColumns()[1];
        Node node = col.children().nextNode();
        assertType(
            "Node identified should be HTMLLinkTag",
            LinkTag.class,
            node);
        LinkTag linkTag = (LinkTag) node;
        Node nodeInsideLink = linkTag.children().nextNode();
        assertType(
            "Tag within link should be an image tag",
            ImageTag.class,
            nodeInsideLink);
        ImageTag imageTag = (ImageTag) nodeInsideLink;
View Full Code Here

        parser.registerScanners();
        parser.addScanner(new TableScanner(parser));
        parseAndAssertNodeCount(1);
        assertType("node should be", TableColumn.class, node[0]);
        TableColumn col = (TableColumn) node[0];
        Node node = col.children().nextNode();
        assertType("node inside column", ImageTag.class, node);
        ImageTag imageTag = (ImageTag) node;
        // Get the data from the node
        assertEquals(
            "Image location",
View Full Code Here

        TableTag table = (TableTag) node[1];
        assertEquals("rows", 3, table.getRowCount());
        TableRow tr = table.getRow(2);
        assertEquals("columns", 1, tr.getColumnCount());
        TableColumn td = tr.getColumns()[0];
        Node node = td.childAt(0);
        assertType("node", TableTag.class, node);
        TableTag table2 = (TableTag) node;
        assertEquals("second table row count", 1, table2.getRowCount());
        tr = table2.getRow(0);
        assertEquals("second table col count", 2, tr.getColumnCount());
View Full Code Here

                + "</body>"
                + "</html>");
        parser.registerScanners();
        for (NodeIterator i = parser.elements(); i.hasMoreNodes();)
        {
            Node node = i.nextNode();
            System.out.println(node.toHtml());
        }
    }
View Full Code Here

        if (children() != null)
        {
            sb.append("  " + "LinkData\n");
            sb.append("  " + "--------\n");

            Node node;
            int i = 0;
            for (SimpleNodeIterator e = children(); e.hasMoreNodes();)
            {
                node = (Node) e.nextNode();
                sb.append("   " + (i++) + " ");
                sb.append(node.toString() + "\n");
            }
        }
        sb.append("  " + "*** END of LinkData ***\n");
        return sb.toString();
    }
View Full Code Here

    public void crawl(Parser parser, int crawlDepth) throws ParserException
    {
        System.out.println(" crawlDepth = " + crawlDepth);
        for (NodeIterator e = parser.elements(); e.hasMoreNodes();)
        {
            Node node = e.nextNode();
            if (node instanceof LinkTag)
            {
                LinkTag linkTag = (LinkTag) node;
                {
                    if (!linkTag.isMailLink())
View Full Code Here

        HttpURLConnection connection;
        StringBuffer buffer;
        PrintWriter out;
        boolean pass;
        NodeIterator enumeration;
        Node node;
        StringNode string;

        try
        {
            url =
View Full Code Here

    {
        String path;
        File file;
        PrintWriter out;
        Parser parser;
        Node nodes[];
        int i;
        NodeIterator enumeration;

        path = System.getProperty("user.dir");
        if (!path.endsWith(File.separator))
View Full Code Here

TOP

Related Classes of org.htmlparser.Node

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.