• 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
Bartender
Posts: 18469
61
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"?
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!