Ciao; ti invio una mia classe che ho utilizzato per leggere un file xml da un URL; spero ti sia utile; ciao.
codice:import java.util.Map; import java.net.URL; import java.io.Serializable; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.io.IOException; import java.util.Iterator; public class ReadStream implements Serializable { //http://192.168.xx.yyy:8080/SiteAdmin/xmlStructure public String pmInterrogation() { StringBuffer sf = new StringBuffer(getConnectionString()); try { return readStream(((HttpURLConnection) (getUrl(sf.toString()). openConnection()))); } catch (IOException ex) { throw new IllegalArgumentException("Error while reading: " + ex.getMessage()); } } private URL getUrl(String url) throws MalformedURLException { return new URL(url); } private String getConnectionString() { StringBuffer sf = new StringBuffer( "http://192.168.xx.yyy:8080/SiteAdmin/xmlStructure"); return sf.toString(); } private String readStream(HttpURLConnection theConn) throws IOException { theConn.connect(); int read = -1; StringBuffer sb = new StringBuffer(); while ((read = theConn.getInputStream().read()) != -1) { sb.append(((char) (read))); } theConn.disconnect(); return sb.toString(); } public static void main(String[] main) { try { Map m = (new Parser()).getElements(ReadXMLString.getInstance((new ReadStream()).pmInterrogation()).getJDomDocument(), "FWD-001-005-001"); for( Iterator i = m.keySet().iterator(); i.hasNext(); ){ System.out.println( m.get( i.next() ) ); } } catch (Exception ex) { ex.printStackTrace(); } } }