Bonjour,
J'ai un projet java a realiser et je rencontre un probleme. Je dois realiser un parser pour des fichiers xml. Pour l'instant, j'essaie deja de lire un fichier xml a partir de son url et de retourner le resultat dans un string.
Le code est le suivant :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
 
 
/*
 * parser test for Pinnacle
 */
 
public class Main  {
 
    /** Method get_page_content
     * Retrive the content of a page and return it in a string
     * @param xml_url
     * @return the content of a page or "" if it fails
     */
    protected static String get_page_content( String xml_url ) {
 
        try{
            URL url = new URL( xml_url );
            BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream()));
            String page_content = "";
            while( br.ready() )
                page_content = page_content + br.readLine() + '\n'; // '\n' is optional
            return page_content;
        } catch(Exception e){
            System.err.println(e.getMessage());
        }
 
        return null;
    }
 
	public static void main (String args[]){
		get_page_content("http://xml.pinnaclesports.com/xmlfeed.asp?contest=no");
	}
}


L'url du fichier xml que je veux lire est : http://xml.pinnaclesports.com/xmlfeed.asp?contest=no

J'obtiens l'erreur suivante en lancant mon programme :
Connection timed out: connect

Quelqu'un a-t-il deja ete confronte a ce genre d'erreur et pourrait-il m'aider?
Merci