Package org.htmlparser

Examples of org.htmlparser.Tag.toHtml()


    // 取得页面内容中标签为"dl"
    NodeList nodeList = parser.extractAllNodesThatMatch(filter);

    Tag tag = (Tag) nodeList.elementAt(0);

    return tag.toHtml();
  }

  /**
   * 解释乐视网 MV音乐
   *
 
View Full Code Here


        // The second node should be a normal tag
        assertTrue("Node 3 should be a normal Tag",node[2] instanceof Tag);
        Tag htag = (Tag)node[2];
        assertStringEquals("Contents of the tag",contents,htag.getText());
        assertStringEquals("html",jsp,htag.toHtml());
        // The third node should be an JspTag
        assertTrue("Node 5 should be an JspTag",node[4] instanceof JspTag);
        JspTag tag2 = (JspTag)node[4];
        assertStringEquals("Contents of the tag",contents2,tag2.getText());
    }
View Full Code Here

        );
        Tag endTag = (Tag)node[2];
        assertStringEquals(
            "third custom tag html",
            tag3,
            endTag.toHtml()
        );
    }

    public void testParentConnections() throws ParserException {
        String tag1 = "<custom>";
View Full Code Here

        Tag endTag = (Tag)node[2];
        assertStringEquals(
            "third custom tag html",
            tag3,
            endTag.toHtml()
        );
        assertNull(
            "end tag should have no parent",
            endTag.getParent()
        );
View Full Code Here

        attributes.add (new Attribute (" "));
        // String String, String, char
        attributes.add (new Attribute ("name", "=", "topFrame", '"'));
        tag = new TagNode (null, 0, 0, attributes);
        html = "<wombat label=\"The civil war.\" frameborder= no name=\"topFrame\">";
        assertStringEquals ("tag contents", html, tag.toHtml ());
    }

    /**
     * Test bean properties.
     */
 
View Full Code Here

        assertTrue ("should be valued", attribute.isValued ());
        assertTrue ("should not be empty", !attribute.isEmpty ());
        attributes.add (attribute);
        tag = new TagNode (null, 0, 0, attributes);
        html = "<wombat label=\"The civil war.\" frameborder= no name=\"topFrame\">";
        assertStringEquals ("tag contents", html, tag.toHtml ());
    }

    /**
     * Test constructors.
     */
 
View Full Code Here

        attributes.add (new PageAttribute (" "));
        // String String, String, char
        attributes.add (new PageAttribute ("name", "=", "topFrame", '"'));
        tag = new TagNode (null, 0, 0, attributes);
        html = "<wombat label=\"The civil war.\" frameborder= no name=\"topFrame\">";
        assertStringEquals ("tag contents", html, tag.toHtml ());
    }

    /**
     * Test bean properties.
     */
 
View Full Code Here

        assertTrue ("should be valued", attribute.isValued ());
        assertTrue ("should not be empty", !attribute.isEmpty ());
         attributes.add (attribute);
        tag = new TagNode (null, 0, 0, attributes);
        html = "<wombat label=\"The civil war.\" frameborder= no name=\"topFrame\">";
        assertStringEquals ("tag contents", html, tag.toHtml ());
    }

    /**
     * Test simple value.
     */
 
View Full Code Here

        String html = "<a>Revision</a>";
        createParser(html,"http://www.yahoo.com");
        parseAndAssertNodeCount(1);
        assertTrue("Node 0 should be a tag",node[0] instanceof Tag);
        Tag tag = (Tag)node[0];
        assertEquals("Tag Contents",html,tag.toHtml());
        assertEquals("Node 0 should have one child", 1, tag.getChildren ().size ());
        assertTrue("The child should be a string node", tag.getChildren ().elementAt (0) instanceof Text);
        Text stringNode = (Text)tag.getChildren ().elementAt (0);
        assertEquals("Text Contents","Revision",stringNode.getText());
    }
View Full Code Here

        createParser(html);
        parser.setNodeFactory (new PrototypicalNodeFactory (true));
        parseAndAssertNodeCount(1);
        assertType("should be Tag",Tag.class,node[0]);
        Tag tag = (Tag)node[0];
        assertStringEquals("html",html,tag.toHtml());
        assertStringEquals("attribute","a<b",tag.getAttribute("att"));
    }

    /**
     * The following multi line test cases are from
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.