Package org.htmlparser.filters

Examples of org.htmlparser.filters.NodeClassFilter


                }));
        parseAndAssertNodeCount(1);
        assertType("html tag",Html.class,node[0]);
        Html html = (Html)node[0];
        NodeList nodeList = new NodeList();
        NodeClassFilter filter = new NodeClassFilter (TitleTag.class);
        html.collectInto(nodeList, filter);
        assertEquals("nodelist size",1,nodeList.size());
        Node node = nodeList.elementAt(0);
        assertType("expected title tag",TitleTag.class,node);
        TitleTag titleTag = (TitleTag)node;
View Full Code Here


    protected String getTextAtNode(NodeList nodeList, int index) {
        Node node = nodeList.elementAt(index);

        NodeList textNode = new NodeList();
        node.collectInto(textNode, new NodeClassFilter(Text.class));

        return textNode.elementAt(0).getText();
    }
View Full Code Here

        if (nodeList.size() > 0) {
            Node first = nodeList.elementAt(0);
            nodeList = new NodeList();
            Node parent = first.getChildren() != null && first.getChildren().size() > 0?first:first.getParent();

            parent.collectInto(nodeList, new NodeClassFilter(Text.class));
            text = nodeList.toHtml(true).replaceAll(" ", "").trim();
        }

        return text;
    }
View Full Code Here

TOP

Related Classes of org.htmlparser.filters.NodeClassFilter

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.