Bonjour,
Je parse un fichier xml qui se trouve sur mon serveur local mais j'ai un probleme lors de l'execution
Version imprimable
Bonjour,
Je parse un fichier xml qui se trouve sur mon serveur local mais j'ai un probleme lors de l'execution
Bonjour,
http://developer.android.com/referen...xception%28%29
Voici ton erreur
Citation:
The exception that is thrown when an application attempts to perform a networking operation on its main thread.
This is only thrown for applications targeting the Honeycomb SDK or higher. Applications targeting earlier SDK versions are allowed to do networking on their main event loop threads, but it's heavily discouraged. See the document Designing for Responsiveness.
merci mais ceci ne resout pas le probleme
problème d'url lors de parsage est ce qu'ilya un forme d'url pour parser ou quoi!??
c'est un un problème d'apache apparament mais comment ajouter les droits d'acces à mon fichier xml sur apache?
Fait voir ton code
Cette classe ou je parse et je recupere les donnes
Code:
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52 public class ContainerData { static public Context context; public ContainerData() { } public static ArrayList<Data> getFeeds(){ // On passe par une classe factory pour obtenir une instance de sax SAXParserFactory fabrique = SAXParserFactory.newInstance(); SAXParser parseur = null; ArrayList<Data> entries = null; try { // On "fabrique" une instance de SAXParser parseur = fabrique.newSAXParser(); } catch (ParserConfigurationException e) { e.printStackTrace(); } catch (SAXException e) { e.printStackTrace(); } // On défini l'url du fichier XML URL url = null; try { url = new URL("http://localhost/tourismee/web/backend_dev.php/api/data.xml"); } catch (MalformedURLException e1) { e1.printStackTrace(); } /* * Le handler sera gestionnaire du fichier XML c'est à dire que c'est lui qui sera chargé * des opérations de parsing. On vera cette classe en détails ci après. */ DefaultHandler handler = new ParserXMLHandler(); try { // On parse le fichier XML InputStream input = url.openStream(); if(input==null) Log.e("erreur android","null"); else{ parseur.parse(input, handler); // On récupère directement la liste des feeds entries = ((ParserXMLHandler) handler).getData(); } } catch (SAXException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } // On la retourne l'array list return entries; } }
Et t'as quoi comme code à la linge 16 de ton main?
Même fait voir ton main en entier pour voir.
Et comme l'a dit Feanorin, sur le lien qu'il t'as passé, t'as une explication ...