Package org.htmlparser.tags

Examples of org.htmlparser.tags.ScriptTag


          if (link.getChild(0) instanceof ImageTag){
            ImageTag img = (ImageTag)link.getChild(0);
            binUrlStr = img.getImageURL();
          }
        } else if (node instanceof ScriptTag){
          ScriptTag script = (ScriptTag)node;
          binUrlStr = script.getAttribute("src");
        } else if (node instanceof LinkTagTag){
          LinkTagTag script = (LinkTagTag)node;
          binUrlStr = script.getAttribute("href");
        }
       
                if (binUrlStr == null)
                {
                    continue;
View Full Code Here


        // Register the image scanner
        parser.addScanner(new ScriptScanner("-s"));
        parseAndAssertNodeCount(1);
        assertTrue("Node should be a script tag", node[0] instanceof ScriptTag);
        // Check the data in the applet tag
        ScriptTag scriptTag = (ScriptTag) node[0];
        Hashtable table = scriptTag.getAttributes();
        String srcExpected = (String) table.get("SRC");
        assertEquals(
            "Expected SRC value",
            "../js/DetermineBrowser.js",
            srcExpected);
View Full Code Here

        sb2.append(" document.write ('yyy');\r\n");
        String testHTML2 = new String(sb2.toString());

        assertTrue("Node should be a script tag", node[1] instanceof ScriptTag);
        // Check the data in the applet tag
        ScriptTag scriptTag = (ScriptTag) node[1];
        String s = scriptTag.getScriptCode();
        assertStringEquals("Expected Script Code", testHTML2, s);
    }
View Full Code Here

        //parser.addScanner(new HTMLScriptScanner("-s"));

        parseAndAssertNodeCount(1);
        assertTrue("Node should be a script tag", node[0] instanceof ScriptTag);
        // Check the data in the applet tag
        ScriptTag scriptTag = (ScriptTag) node[0];
        //assertStringEquals("Expected Script Code",testHTML2,scriptTag.getScriptCode());
    }
View Full Code Here

        // Register the image scanner
        parser.registerScanners();
        parseAndAssertNodeCount(1);
        assertTrue("Node should be a script tag", node[0] instanceof ScriptTag);
        // Check the data in the applet tag
        ScriptTag scriptTag = (ScriptTag) node[0];
        String scriptCode = scriptTag.getScriptCode();
        String expectedCode =
            "<!--\r\n"
                + "  function validateForm()\r\n"
                + "  {\r\n"
                + "     var i = 10;\r\n"
View Full Code Here

                + "</SCRIPT>";
        createParser(testHtml);

        parser.addScanner(new ScriptScanner("-s"));
        parseAndAssertNodeCount(1);
        ScriptTag scriptTag = (ScriptTag) node[0];
        assertStringEquals("scriptag html", testHtml, scriptTag.toHtml());
    }
View Full Code Here

                + "</body>"
                + "</html>");
        parser.registerScanners();
        Node scriptNodes[] = parser.extractAllNodesThatAre(ScriptTag.class);
        assertType("scriptnode", ScriptTag.class, scriptNodes[0]);
        ScriptTag scriptTag = (ScriptTag) scriptNodes[0];
        assertStringEquals(
            "script code",
            "document.write(\"<script "
                + "language=\\\"JavaScript\\\">\");"
                + "document.write(\"function onmousedown"
                + "(event)\");"
                + "document.write(\"{ // do something\"); "
                + "document.write(\"}\"); "
                + "// parser thinks this is the end tag. "
                + "document.write(\"</script>\");",
            scriptTag.getScriptCode());

    }
View Full Code Here

                + "width=\"80\" height=\"20\" border=\"0\"></a>\");"
                + "</SCRIPT>");
        parser.registerScanners();
        parseAndAssertNodeCount(1);
        assertType("script", ScriptTag.class, node[0]);
        ScriptTag scriptTag = (ScriptTag) node[0];
        assertStringEquals(
            "script code",
            "document.write(\"<a href=\"1.htm\"><img src=\"1.jpg\" "
                + "width=\"80\" height=\"20\" border=\"0\"></a>\");",
            scriptTag.getScriptCode());
    }
View Full Code Here

                + "width=\\\"80\\\" height=\\\"20\\\" border=\\\"0\\\"></a>\");"
                + "</SCRIPT>");
        parser.registerScanners();
        parseAndAssertNodeCount(1);
        assertType("script", ScriptTag.class, node[0]);
        ScriptTag scriptTag = (ScriptTag) node[0];
        assertStringEquals(
            "script code",
            "document.write(\"<a href=\\\"1.htm\\\"><img src=\\\"1.jpg\\\" "
                + "width=\\\"80\\\" height=\\\"20\\\" border=\\\"0\\\"></a>\");",
            scriptTag.getScriptCode());
    }
View Full Code Here

        String scriptContents = "alert()\r\nalert()";
        createParser("<script>" + scriptContents + "</script>");
        parser.registerScanners();
        parseAndAssertNodeCount(1);
        assertType("script", ScriptTag.class, node[0]);
        ScriptTag scriptTag = (ScriptTag) node[0];
        assertStringEquals(
            "script code",
            scriptContents,
            scriptTag.getScriptCode());
    }
View Full Code Here

TOP

Related Classes of org.htmlparser.tags.ScriptTag

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.