Package org.htmlparser.filters
package org.htmlparser.filters
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);
-
ClassesClassDescriptionAccepts nodes matching all of its predicate filters (AND operation).A NodeFilter that accepts nodes based on whether they match a CSS2 selector.This class accepts all tags that have a certain attribute, and optionally, with a certain value.This class accepts all tags that have a child acceptable to the filter.This class accepts all tags that have a parent acceptable to another filter.This class accepts all tags that have a sibling acceptable to another filter.This class accepts only one specific node.This class accepts tags of class LinkTag that contain a link matching a given regex pattern.This class accepts tags of class LinkTag that contain a link matching a given pattern string.This class accepts all tags of a given class.Accepts all nodes not acceptable to it's predicate filter.Accepts nodes matching any of its predicates filters (OR operation).This filter accepts all string nodes matching a regular expression.This class accepts all string nodes containing the given string.This class accepts all tags matching the tag name.Accepts nodes matching an odd number of its predicates filters (XOR operation).