Can Some one tell me whats wrong here?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • thatos
    New Member
    • Aug 2007
    • 105

    Can Some one tell me whats wrong here?

    When I run this program
    Code:
    import au.id.jericho.lib.html.*;
    import java.util.*;
    import java.io.*;
    import java.net.*;
    
    public class DisplayAllElements {
    	public static void main(String[] args) throws Exception {
    		String sourceUrlString="data/test.html";
    		if (args.length==0)
    		  System.err.println("Using default argument of \""+sourceUrlString+'"');
    		else
    			sourceUrlString=args[0];
    		if (sourceUrlString.indexOf(':')==-1) sourceUrlString="file:"+sourceUrlString;
    		PHPTagTypes.register();
    		PHPTagTypes.PHP_SHORT.deregister(); // remove PHP short tags for this example otherwise they override processing instructions
    		MasonTagTypes.register();
    		Source source=new Source(new URL(sourceUrlString));
    		List elementList=source.findAllElements();
    		for (Iterator i=elementList.iterator(); i.hasNext();) {
    			Element element=(Element)i.next();
    			System.out.println("-------------------------------------------------------------------------------");
    			System.out.println(element.getDebugInfo());
    			if (element.getAttributes()!=null) System.out.println("XHTML StartTag:\n"+element.getStartTag().tidy(true));
    			System.out.println("Source text with content:\n"+element);
    		}
    		System.out.println(source.getCacheDebugInfo());
      }
    }
    I get the following error
    Code:
    Using default argument of "E:/project/jericho-html-2.5/samples/console/data/test.html"
    Exception in thread "main" java.net.MalformedURLException: unknown protocol: e
    	at java.net.URL.<init>(Unknown Source)
    	at java.net.URL.<init>(Unknown Source)
    	at java.net.URL.<init>(Unknown Source)
    	at DisplayAllElements.main(DisplayAllElements.java:17)
    How can I resolve the following error?
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by thatos
    When I run this program
    Code:
    import au.id.jericho.lib.html.*;
    import java.util.*;
    import java.io.*;
    import java.net.*;
    
    public class DisplayAllElements {
    	public static void main(String[] args) throws Exception {
    		String sourceUrlString="data/test.html";
    		if (args.length==0)
    		  System.err.println("Using default argument of \""+sourceUrlString+'"');
    		else
    			sourceUrlString=args[0];
    		if (sourceUrlString.indexOf(':')==-1) sourceUrlString="file:"+sourceUrlString;
    		PHPTagTypes.register();
    		PHPTagTypes.PHP_SHORT.deregister(); // remove PHP short tags for this example otherwise they override processing instructions
    		MasonTagTypes.register();
    		Source source=new Source(new URL(sourceUrlString));
    		List elementList=source.findAllElements();
    		for (Iterator i=elementList.iterator(); i.hasNext();) {
    			Element element=(Element)i.next();
    			System.out.println("-------------------------------------------------------------------------------");
    			System.out.println(element.getDebugInfo());
    			if (element.getAttributes()!=null) System.out.println("XHTML StartTag:\n"+element.getStartTag().tidy(true));
    			System.out.println("Source text with content:\n"+element);
    		}
    		System.out.println(source.getCacheDebugInfo());
      }
    }
    I get the following error
    Code:
    Using default argument of "E:/project/jericho-html-2.5/samples/console/data/test.html"
    Exception in thread "main" java.net.MalformedURLException: unknown protocol: e
    	at java.net.URL.<init>(Unknown Source)
    	at java.net.URL.<init>(Unknown Source)
    	at java.net.URL.<init>(Unknown Source)
    	at DisplayAllElements.main(DisplayAllElements.java:17)
    How can I resolve the following error?
    1.) Please don't keep starting multiple threads for the same question. I have already asked you not to do this before.
    2.) Before line 17 i.e before this line
    Code:
    Source source=new Source(new URL(sourceUrlString));
    put println as
    Code:
    System.out.println(sourceURLString);
    Now open the API specs for the URL class and check your value printed above against the requirements of a valid URL.

    Comment

    Working...