Package org.htmlparser

Examples of org.htmlparser.Parser


  }

  @Override
  public void visitTextFragment(final VisitorContext ctx, TextFragment text) {
    final List<MessageFragment> result = new ArrayList<MessageFragment>();
    Parser parser = Parser.createParser(text.getText(), "UTF-8");
    try {
      parser.visitAllNodesWith(new NodeVisitor() {
        @Override
        public void visitEndTag(Tag tag) {
          result.add(ctx.createNonlocalizableTextFragment(tag.toHtml(true)));
        }
View Full Code Here


     * @see org.apache.jmeter.protocol.http.parser.HtmlParser#getEmbeddedResourceURLs(byte[], java.net.URL)
     */
    public Iterator getEmbeddedResourceURLs(byte[] html, URL baseUrl, URLCollection urls)
        throws HTMLParseException
    {
        Parser htmlParser= null;
        try
        {
            String contents= new String(html);
            StringReader reader= new StringReader(contents);
            NodeReader nreader= new NodeReader(reader, contents.length());
            htmlParser= new Parser(nreader, new DefaultParserFeedback());
            addTagListeners(htmlParser);
        }
        catch (Exception e)
        {
            throw new HTMLParseException(e);
        }

        // Now parse the DOM tree

        // look for applets

        // This will only work with an Applet .class file.
        // Ideally, this should be upgraded to work with Objects (IE)
        //  and archives (.jar and .zip) files as well.

        try
        {
            // we start to iterate through the elements
            for (NodeIterator e= htmlParser.elements(); e.hasMoreNodes();)
            {
                Node node= e.nextNode();
                String binUrlStr= null;

                // first we check to see if body tag has a
View Full Code Here

        super(name);
    }

    public void testUrlModificationWithVisitor() throws Exception
    {
        Parser parser = Parser.createParser(HTML_WITH_LINK);
        UrlModifyingVisitor visitor =
            new UrlModifyingVisitor(parser, "localhost://");
        parser.visitAllNodesWith(visitor);
        assertStringEquals(
            "Expected HTML",
            MODIFIED_HTML,
            visitor.getModifiedResult());
    }
View Full Code Here

    /** Creates new StringBean */
    public LinkBean()
    {
        mPropertySupport = new PropertyChangeSupport(this);
        mLinks = null;
        mParser = new Parser();
    }
View Full Code Here

    // internals
    //

    protected URL[] extractLinks(String url) throws ParserException
    {
        Parser parser;
        Vector vector;
        Node node;
        LinkTag link;
        URL[] ret;

        parser = new Parser(url);
        parser.registerScanners();
        ObjectFindingVisitor visitor = new ObjectFindingVisitor(LinkTag.class);
        parser.visitAllNodesWith(visitor);
        Node[] nodes = visitor.getTags();
        vector = new Vector();
        for (int i = 0; i < nodes.length; i++)
            try
            {
View Full Code Here

     */
    public StringBean()
    {
        super(true, false);
        mPropertySupport = new PropertyChangeSupport(this);
        mParser = new Parser();
        mStrings = null;
        mLinks = false;
        mReplaceSpace = true;
        mCollapse = true;
    }
View Full Code Here

            || ((null != old) && !old.equals(url)))
        {
            try
            {
                if (null == mParser)
                    mParser = new Parser(url);
                else
                    mParser.setURL(url);
                mPropertySupport.firePropertyChange(
                    PROP_URL_PROPERTY,
                    old,
View Full Code Here

            || ((null != conn) && !conn.equals(connection)))
        {
            try
            {
                if (null == mParser)
                    mParser = new Parser(connection);
                else
                    mParser.setConnection(connection);
                mPropertySupport.firePropertyChange(
                    PROP_URL_PROPERTY,
                    url,
View Full Code Here

     * See feature request #729259 Increase maximum recursion depth.
     * Only perform this test if it's version 1.4 or higher.
     */
    public void testRecursionDepth() throws ParserException
    {
        Parser parser;
        String url = "http://htmlparser.sourceforge.net/test/badtable2.html";

        parser = new Parser(url);
        if (1.4 <= Parser.getVersionNumber())
        {
            parser.registerScanners();
            for (NodeIterator e = parser.elements(); e.hasMoreNodes();)
                e.nextNode();
            // Note: The test will throw a StackOverFlowException,
            // so we are successful if we get to here...
            assertTrue("Crash", true);
        }
View Full Code Here

     */
    public Robot(String resourceLocation)
    {
        try
        {
            parser = new Parser(resourceLocation, new DefaultParserFeedback());
            parser.registerScanners();
        }
        catch (ParserException e)
        {
            System.err.println("Error, could not create parser object");
View Full Code Here

TOP

Related Classes of org.htmlparser.Parser

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.