Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Get an xml document from an URL address

 
stina karlsson
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am writing an applet and needs to get an xml document from a specified URL. I have no problems compiling the Applet, but when I run the applet in a browser there is something that goes wrong in the docBuilderFactory.newDocumentBuilder(). Is there anyone that knows what I do wrong?
thanks,
Stina
public Document getDocumentByURL() throws Exception{
DocumentBuilderFactory docBuilderFactory;
DocumentBuilder docBuilder;
Document doc;
docBuilderFactory = DocumentBuilderFactory.newInstance();
docBuilder = docBuilderFactory.newDocumentBuilder();
doc = docBuilder.parse(theURL);
return doc;
}
 
Jonathan W. Brett
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I had the same problem and mine stemmed from a library problem . . .heres what I ended up using.
javax.xml.parsers.DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
javax.xml.parsers.DocumentBuilder builder = factory.newDocumentBuilder();
document = builder.parse(the url);
------------------
Jonathan Brett, SCJP
 
stina karlsson
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply Jonathan! Well, I have tried what you suggested now, but it still does not work. :-(
Is there anyone who has any other suggestions?
 
Tim Holloway
Saloon Keeper
Posts: 18366
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is your server setting the MIME type to "text/xml"?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic