org.htmlparser.filters

Class CssSelectorNodeFilter

Implemented Interfaces:
Cloneable, NodeFilter, Serializable

public class CssSelectorNodeFilter
extends Object
implements NodeFilter

A NodeFilter that accepts nodes based on whether they match a CSS2 selector. Refer to http://www.w3.org/TR/REC-CSS2/selector.html for syntax.

Todo: more thorough testing, any relevant pseudo-classes, css3 features

Constructor Summary

CssSelectorNodeFilter(String selector)
Create a Cascading Style Sheet node filter.

Method Summary

boolean
accept(Node node)
Accept nodes that match the selector expression.
static String
unescape(String escaped)
Replace escape sequences in a string.

Constructor Details

CssSelectorNodeFilter

public CssSelectorNodeFilter(String selector)
Create a Cascading Style Sheet node filter.
Parameters:
selector - The selector expression.

Method Details

accept

public boolean accept(Node node)
Accept nodes that match the selector expression.
Specified by:
accept in interface NodeFilter
Parameters:
node - The node to check.
Returns:
true if the node matches, false otherwise.

unescape

public static String unescape(String escaped)
Replace escape sequences in a string.
Parameters:
escaped - The string to examine.
Returns:
The argument with escape sequences replaced by their equivalent character.

HTML Parser is an open source library released under LGPL. SourceForge.net