Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

path for xml file

 
Sebastian Green
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have tired both SAX & JAXP to parse xml-files. It works fine if give the parser an absolute path to file (C:\\demo.xml). But what I really want to is give a an url (http://localhost/demo.xml). Is it possible for an more dynamic sollution then the first case?
 
Vladas Razas
Ranch Hand
Posts: 385
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you put your xml on web server?
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Sebastian Green:
I have tired both SAX & JAXP to parse xml-files. It works fine if give the parser an absolute path to file (C:\\demo.xml). But what I really want to is give a an url (http://localhost/demo.xml). Is it possible for an more dynamic sollution then the first case?

Make your API to take the XML as a java.io.InputStream instead of File or String. Then, if you need to parse a local file, pass in a new FileInputStream("C:\\demo.xml"), and when you need to parse a remote file on a web server, pass in new URL("http://localhost/demo.xml").openStream().
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic