Seth - 2006-12-14

Does anyone have an idea why this NodeFilter is not finding the style tag?

public void testExtractStyle() throws Exception {
    String s = "<html>" +
            "<head>" +
                "<style type=\&quot;text/css\&quot;>.foo {color:#fff}</style>" +
            "</head>" +
            "</html>";
    Parser p = new Parser();
    p.setInputHTML( s );
    NodeList all = p.parse( null );
//    NodeList styles = all.extractAllNodesThatMatch( new AndFilter( new TagNameFilter("style"), new HasAttributeFilter("type", "text/css")), true );
    NodeList styles = all.extractAllNodesThatMatch( new TagNameFilter("style") );
    assertEquals( 1, styles.size() );
}

The assertion fails as is, but passes if I use the AndFilter in the commented out line.