Package org.htmlparser.filters

Examples of org.htmlparser.filters.HasAttributeFilter


     */
    public HasAttributeFilterWrapper ()
    {
        String value;

        mFilter = new HasAttributeFilter ();

        // add the attribute name choice
        mAttributeName = new JComboBox ();
        mAttributeName.setEditable (true);
        add (mAttributeName);
View Full Code Here


     * Get the underlying node filter object.
     * @return The node filter object suitable for serialization.
     */
    public NodeFilter getNodeFilter ()
    {
        HasAttributeFilter ret;
       
        ret = new HasAttributeFilter ();
        ret.setAttributeName (mFilter.getAttributeName ());
        ret.setAttributeValue (mFilter.getAttributeValue ());
           
        return (ret);
    }
View Full Code Here

            // <meta name="robots" content="index,follow" />
            // <meta name="robots" content="noindex,nofollow" />
            robots = list.extractAllNodesThatMatch (
                new AndFilter (
                    new NodeClassFilter (MetaTag.class),
                    new HasAttributeFilter ("name", "robots")), true);
            if (0 != robots.size ())
            {
                robot = (MetaTag)robots.elementAt (0);
                content = robot.getAttribute ("content").toLowerCase ();
                if ((-1 != content.indexOf ("none")) || (-1 != content.indexOf ("nofollow")))
View Full Code Here

        NodeList list;

        guts = "<body>Now is the <a id=target><b>time</b></a> for all good <a href=http://bongo.com>men</a>..</body>";
        html = "<html>" + guts + "</html>";
        createParser (html);
        list = parser.extractAllNodesThatMatch (new HasAttributeFilter ("id"));
        assertEquals ("only one element", 1, list.size ());
        assertType ("should be LinkTag", LinkTag.class, list.elementAt (0));
        LinkTag link = (LinkTag)list.elementAt (0);
        assertEquals ("attribute value", "target", link.getAttribute ("id"));
    }
View Full Code Here

                    new HasAttributePrefixFilter("id", parentIdPrefix))
    );

    NodeFilter predicates[] = {
            new TagNameFilter(childTag),
            new HasAttributeFilter("class", tagClass)
    };
    NodeFilter filter = new AndFilter(predicates);
    NodeList matches = parents.extractAllNodesThatMatch(filter, true);
    return matches.size();
  }
View Full Code Here

  public String valueOfTagWithIdIs(String id) throws Exception {
    return getValueOfTagWithAttributeValue("id", id);
  }

  private String getValueOfTagWithAttributeValue(String attribute, String value) throws Exception {
    NodeList matches = getMatchingTags(new HasAttributeFilter(attribute, value));
    if (matches.size() != 1)
      return String.format("There are %d matches, there should be 1.", matches.size());
    else
      return matches.elementAt(0).toHtml();
  }
View Full Code Here

        }
    }

    protected TableTag getReportTable(Parser htmlParser) throws ParserException {
        final AndFilter filter = new AndFilter(new TagNameFilter(TABLE_TAG_NAME),
                new HasAttributeFilter(CLASS_ATTR_NAME, REPORT_CLASS_VALUE));

        NodeList reportNode = htmlParser.extractAllNodesThatMatch(filter);
        if (!(reportNode != null && reportNode.size() > 0)) {
            throw new ParserException("cannot parse rcov report file, report element wasn't found");
        }
View Full Code Here

    private String parseSourceInTableDetails(String html) throws FileNotFoundException, ParserException, IOException {
        String source = null;

        final Parser htmlParser = initParser(html);
        final AndFilter filter = new AndFilter(new TagNameFilter(TABLE_TAG_NAME),
                new HasAttributeFilter(CLASS_ATTR_NAME, "details"));

        NodeList reportNode = htmlParser.extractAllNodesThatMatch(filter);
        if (reportNode != null && reportNode.size() > 0) {
            source = ((TableTag) reportNode.elements().nextNode()).toHtml(true);
        }
View Full Code Here

            // recurseHtmlNodes(nodelist, base);
        } // else maybe it is a parsed Flash document? Anyone? :-)
    }
   
    private void processHtml(HttpUrl base, NodeList nodelist) {
        NodeFilter filter = new HasAttributeFilter("href");
        filter = new OrFilter(filter, new HasAttributeFilter("src"));
        filter = new OrFilter(filter, new HasAttributeFilter("onclick"));
        filter = new OrFilter(filter, new HasAttributeFilter("onblur"));
        try {
            NodeList links = nodelist.extractAllNodesThatMatch(filter);
            for (NodeIterator ni = links.elements(); ni.hasMoreNodes(); ) {
                Node node = ni.nextNode();
                if (node instanceof Tag) {
View Full Code Here

TOP

Related Classes of org.htmlparser.filters.HasAttributeFilter

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.