IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

ActionScript 3 Discussion :

parser xml fichier de config air


Sujet :

ActionScript 3

  1. #1
    Membre confirmé
    Inscrit en
    Mars 2006
    Messages
    117
    Détails du profil
    Informations personnelles :
    Âge : 42

    Informations forums :
    Inscription : Mars 2006
    Messages : 117
    Par défaut parser xml fichier de config air
    bonjour,

    ca fait plusieurs heures que je m'arrache les cheveux sans comprendre d'ou vient le probleme...

    J'essaye de parser le fichier de config de l'application Air que je lance.

    mon projet s'appel checkversion (mon but apres est de l'incorporer dans un plus gros projet pour pour mettre en place un systeme de mise à jours automatique... mais c'est une autre historie). J'arrive bien a trouver le fichier xml, à l'afficher, mais quand j'essaye de le parser il ne se passe rien...

    voici mon code de mon fichier as :

    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
    37
    38
    39
    40
     
    package utils
    {
    	import flash.events.Event;
    	import flash.filesystem.File;
    	import flash.net.URLLoader;
    	import flash.net.URLRequest;
     
    	import mx.controls.Alert;
     
    	public class PviUpdater
    	{
    		public function PviUpdater()
    		{
    		}
     
     
    		public static function GetVersion():void
    		{
     
    		var loader:URLLoader = new URLLoader();
               	loader.addEventListener(Event.COMPLETE, readVersion);
               	var request:URLRequest = new URLRequest(File.applicationDirectory.resolvePath("checkversion-app.xml").url);
               	loader.load(request);
     
     
    		}
     
    		private static function readVersion(event:Event):void
    	{
    		var load:URLLoader = URLLoader(event.target);
           	var parser:XML = XML(load.data);
     
    		Alert.show(parser.version); 
    	}
     
    	}
     
     
    }
    dans la popup quoique je mette venant du parser il ne se passe rien ...
    par contre load.data contient bien le fichier xml entier.

    please help sinon je vais devenir chauve lol !

    D'avance merci de vos reponses,


    Oniric

    ps: je suis assez novice en flex/as3 si vous avez des choses à redire sur le reste hesitez pas

  2. #2
    Membre confirmé
    Inscrit en
    Mars 2006
    Messages
    117
    Détails du profil
    Informations personnelles :
    Âge : 42

    Informations forums :
    Inscription : Mars 2006
    Messages : 117
    Par défaut
    personne n'a d'idée ?

    j'ai fait d'autre test et le mystere reste entier.... quand je prend un autre fichier xml au meme endroit mais sans commentaire et plus petit, ca fonctionne tres bien... pourtant le "gros" fichier j'arrive bien à l'afficher en entier et il retire bien les commentaires.

    Je comprend pas.

    Help !

  3. #3
    Rédacteur/Modérateur
    Avatar de beekeep
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Octobre 2006
    Messages
    2 005
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 40
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Octobre 2006
    Messages : 2 005
    Par défaut
    bonsoir,

    j'ai pas bien compris à quoi correspond le parser.version ?

    il faudrait voir le format de ton fichier pour t'aider à le parser correctement.

  4. #4
    Membre confirmé
    Inscrit en
    Mars 2006
    Messages
    117
    Détails du profil
    Informations personnelles :
    Âge : 42

    Informations forums :
    Inscription : Mars 2006
    Messages : 117
    Par défaut
    si ca interesse des gens j'ai trouvé la solution.

    Le probleme venait du namespace du fichier. il suffit de rajouter :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    parser = XML(localload.data);
    var ns:Namespace = parser.namespace();
    trace(parser.ns::version);
    et ca fonctionne.

    merci moi meme ! lol

  5. #5
    Membre confirmé
    Inscrit en
    Mars 2006
    Messages
    117
    Détails du profil
    Informations personnelles :
    Âge : 42

    Informations forums :
    Inscription : Mars 2006
    Messages : 117
    Par défaut
    pour information pour repondre à ta question beekeep,
    le fichier xml etait le suivant, je pensais l'avoir mis mais non
    sorry de repondre si tard, je n'avais pas vu ton post.

    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
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    <?xml version="1.0" encoding="UTF-8"?>
    <application xmlns="http://ns.adobe.com/air/application/1.0">
     
    <!-- Adobe AIR Application Descriptor File Template.
     
    	Specifies parameters for identifying, installing, and launching AIR applications.
    	See http://www.adobe.com/go/air_1.0_application_descriptor for complete documentation.
     
    	xmlns - The Adobe AIR namespace: http://ns.adobe.com/air/application/1.0
    			The last segment of the namespace specifies the version 
    			of the AIR runtime required for this application to run.
     
    	minimumPatchLevel - The minimum patch level of the AIR runtime required to run 
    			the application. Optional.
    -->
     
    	<!-- The application identifier string, unique to this application. Required. -->
    	<id>checkversion</id>
     
    	<!-- Used as the filename for the application. Required. -->
    	<filename>checkversion</filename>
     
    	<!-- The name that is displayed in the AIR application installer. Optional. -->
    	<name>checkversion</name>
     
    	<!-- An application version designator (such as "v1", "2.5", or "Alpha 1"). Required. -->
    	<version>1</version>
     
    	<!-- Description, displayed in the AIR application installer. Optional. -->
    	<!-- <description></description> -->
     
    	<!-- Copyright information. Optional -->
    	<!-- <copyright></copyright> -->
     
    	<!-- Settings for the application's initial window. Required. -->
    	<initialWindow>
    		<!-- The main SWF or HTML file of the application. Required. -->
    		<!-- Note: In Flex Builder, the SWF reference is set automatically. -->
    		<content>[This value will be overwritten by Flex Builder in the output app.xml]</content>
     
    		<!-- The title of the main window. Optional. -->
    		<!-- <title></title> -->
     
    		<!-- The type of system chrome to use (either "standard" or "none"). Optional. Default standard. -->
    		<!-- <systemChrome></systemChrome> -->
     
    		<!-- Whether the window is transparent. Only applicable when systemChrome is false. Optional. Default false. -->
    		<!-- <transparent></transparent> -->
     
    		<!-- Whether the window is initially visible. Optional. Default false. -->
    		<!-- <visible></visible> -->
     
    		<!-- Whether the user can minimize the window. Optional. Default true. -->
    		<!-- <minimizable></minimizable> -->
     
    		<!-- Whether the user can maximize the window. Optional. Default true. -->
    		<!-- <maximizable></maximizable> -->
     
    		<!-- Whether the user can resize the window. Optional. Default true. -->
    		<!-- <resizable></resizable> -->
     
    		<!-- The window's initial width. Optional. -->
    			<width>640</width>
     
    		<!-- The window's initial height. Optional. -->
    		<height>480</height>
     
    		<!-- The window's initial x position. Optional. -->
    		<!-- <x></x> -->
     
    		<!-- The window's initial y position. Optional. -->
    		<!-- <y></y> -->
     
    		<!-- The window's minimum size, specified as a width/height pair, such as "400 200". Optional. -->
    		<!-- <minSize></minSize> -->
     
    		<!-- The window's initial maximum size, specified as a width/height pair, such as "1600 1200". Optional. -->
    		<!-- <maxSize></maxSize> -->
    	</initialWindow>
     
    	<!-- The subpath of the standard default installation location to use. Optional. -->
    	<!-- <installFolder></installFolder> -->
     
    	<!-- The subpath of the Windows Start/Programs menu to use. Optional. -->
    	<!-- <programMenuFolder></programMenuFolder> -->
     
    	<!-- The icon the system uses for the application. For at least one resolution,
    		 specify the path to a PNG file included in the AIR package. Optional. -->
    	<!-- <icon>
    		<image16x16></image16x16>
    		<image32x32></image32x32>
    		<image48x48></image48x48>
    		<image128x128></image128x128>
    	</icon> -->
     
    	<!-- Whether the application handles the update when a user double-clicks an update version
    	of the AIR file (true), or the default AIR application installer handles the update (false).
    	Optional. Default false. -->
    	<!-- <customUpdateUI></customUpdateUI> -->
     
    	<!-- Whether the application can be launched when the user clicks a link in a web browser.
    	Optional. Default false. -->
    	<!-- <allowBrowserInvocation></allowBrowserInvocation> -->
     
    	<!-- Listing of file types for which the application can register. Optional. -->
    	<!-- <fileTypes> -->
     
    		<!-- Defines one file type. Optional. -->
    		<!-- <fileType> -->
     
    			<!-- The name that the system displays for the registered file type. Required. -->
    			<!-- <name></name> -->
     
    			<!-- The extension to register. Required. -->
    			<!-- <extension></extension> -->
     
    			<!-- The description of the file type. Optional. -->
    			<!-- <description></description> -->
     
    			<!-- The MIME type. Optional. -->
    			<!-- <contentType></contentType> -->
     
    			<!-- The icon to display for the file type. Optional. -->
    			<!-- <icon>
    				<image16x16></image16x16>
    				<image32x32></image32x32>
    				<image48x48></image48x48>
    				<image128x128></image128x128>
    			</icon> -->
     
    		<!-- </fileType> -->
    	<!-- </fileTypes> -->
     
    </application>
    donc parser.version normalement permet d'acceder à la valeur du noeud version. Mais vu que je n'utilisais pas le namespace, il ne trouvait pas le noeud et donc encore moins la valeur
    Avec mon ajout ca fonctionne tres bien

    ps : dingue 42 messages ! sorry, comprennent qui pourra

  6. #6
    Rédacteur/Modérateur
    Avatar de beekeep
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Octobre 2006
    Messages
    2 005
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 40
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Octobre 2006
    Messages : 2 005
    Par défaut
    merci pour ta réponse oniric, ça peut servir à d'autres.

    Citation Envoyé par oniric Voir le message
    ps : dingue 42 messages ! sorry, comprennent qui pourra
    wouaaah, tu vas pouvoir poster dans la taverne

    /!\ derrière un petit nombre de message peut se cacher un expert

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [xslt] Parser 2 fichiers XML
    Par malekms dans le forum XSL/XSLT/XPATH
    Réponses: 4
    Dernier message: 30/12/2005, 12h22
  2. [XML][Java] parser plusieurs fichiers en un seul arbre DOM ?
    Par mrlenul dans le forum XML/XSL et SOAP
    Réponses: 2
    Dernier message: 29/11/2005, 11h09
  3. Parser un fichier XML
    Par Charlinecha dans le forum Format d'échange (XML, JSON...)
    Réponses: 1
    Dernier message: 11/07/2005, 17h18
  4. [SAX] parser un fichier xml en Java
    Par royou dans le forum Format d'échange (XML, JSON...)
    Réponses: 1
    Dernier message: 10/02/2005, 17h12
  5. parser des fichier .xml en perl
    Par djibril dans le forum Modules
    Réponses: 13
    Dernier message: 18/05/2004, 17h08

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo