Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

java.net.MalformedURLException: no protocol:

843834Oct 26 2007 — edited Oct 26 2007
Hi guys, i'm having a small problem parsing an xml. This is what I'm trying to do. I have a list of xml files. I want to parse them, find if they have a <imageLink> tag in them, if they do, I want to extract the content of tag and print it. So i did something pretty basic like this:

DOMParser dp=new DOMParser();
dp.parse(xmlcontent); //xml is a String containing the content of the xml read with FileReader

NodeList tags=dp.getDocument().getElementsByTagName("imageLink");
for(int z=0;z<tags.getLength();z++) out.println("<p>"+tags.item(z).toString()+"</p>");

I get this error message:

java.net.MalformedURLException: no protocol: <companies><companyNotice>2003-01-11</companyNotice></companies>

I am thinking it might have something to do with the fact that my xml files are not "valid"...they are well formed but they don't have that
<?xml version="1.0" encoding="UTF-8"?> tag...there is just the text.

I've googled the error but most of the people having this error had it for different reasons. 10x in advance if anyone figures it out.

Cheers
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 23 2007
Added on Oct 26 2007
1 comment
517 views