Filters Package

The filters package contains example filters to select only desired nodes. For example, to display tags having the "id" attribute, you could use:

    Parser parser = new Parser ("http://yadda");
    parser.parse (new HasAttributeFilter ("id"));

These filters can be combined to yield powerful extraction capabilities. For example, to get a list of links where the contents is an image, you could use:

    NodeList list = new NodeList ();
    NodeFilter filter =
        new AndFilter (
            new TagNameFilter ("A"),
            new HasChildFilter (
                new TagNameFilter ("IMG")));
    for (NodeIterator e = parser.elements (); e.hasMoreNodes (); )
        e.nextNode ().collectInto (list, filter);