Bonjour � tous,

J'aimerai cr�er une petite application en utilisant Visual C++ 2010 Express, malheureusement je rencontre d'�normes difficult�s car je ne suis pas du tout un programmeur c'est pourquoi votre aide me sera d'une grande utilit�.

Explication du probl�me: J'utilise un logiciel graphique me permettant de saisir des sch�mas et qui les enregistre au format XML.

Exemple d'un fichier XML g�n�r� par le logiciel :
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
<?xml version="1.0" encoding="utf-8"?>
<project xmlns="http://www.plcopen.org/xml/tc6.xsd" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <fileHeader companyName="Universita di Napoli Federico II" companyURL="www.unina.it" productName="UniSim" productVersion="0.5.0" productRelease="B" creationDateTime="2007-12-31T23:59:59Z" contentDescription="Application" />
  <contentHeader name="Test2" version="1" organization="TIMA" author="Micka">
    <Comment />
    <coordinateInfo>
      <pageSize x="0" y="0" />
      <fbd>
        <scaling x="1" y="1" />
      </fbd>
      <ld>
        <scaling x="1" y="1" />
      </ld>
      <sfc>
        <scaling x="1" y="1" />
      </sfc>
    </coordinateInfo>
  </contentHeader>
  <types>
    <dataTypes />
    <pous>
      <pou name="Grafcet" pouType="program">
        <interface>
          <localVars name="Grafcet - Local variables">
            <variable name="a">
              <type>
                <BOOL />
              </type>
              <initialValue>
                <simpleValue value="True" />
              </initialValue>
            </variable>
            <variable name="b">
              <type>
                <BOOL />
              </type>
              <initialValue>
                <simpleValue value="False" />
              </initialValue>
            </variable>
          </localVars>
          <tempVars name="Grafcet - Temporary variables" />
          <inputVars name="Grafcet - Input variables" />
          <outputVars name="Grafcet - Output variables" />
          <inOutVars name="Grafcet - InOut variables" />
          <externalVars name="Grafcet - External variables" />
          <accessVars name="Grafcet - Accessible variables" />
          <globalVars name="Grafcet - Global variables" />
        </interface>
        <body>
          <SFC>
            <step name="S0" height="44" width="44" localId="1" initialStep="true" negated="false">
              <position x="350" y="66" />
              <connectionPointIn>
                <connection refLocalId="8" />
              </connectionPointIn>
            </step>
            <step name="S1" height="44" width="44" localId="2" initialStep="false" negated="false">
              <position x="350" y="146" />
              <connectionPointIn>
                <connection refLocalId="5" />
              </connectionPointIn>
            </step>
            <step name="S2" height="44" width="44" localId="3" initialStep="false" negated="false">
              <position x="350" y="238" />
              <connectionPointIn>
                <connection refLocalId="6" />
              </connectionPointIn>
            </step>
            <step name="S3" height="44" width="44" localId="4" initialStep="false" negated="false">
              <position x="350" y="322" />
              <connectionPointIn>
                <connection refLocalId="7" />
              </connectionPointIn>
            </step>
            <transition height="44" width="44" localId="5">
              <position x="368" y="128" />
              <connectionPointIn>
                <connection refLocalId="1" />
              </connectionPointIn>
              <condition>
                <reference name="a" />
              </condition>
            </transition>
            <transition height="44" width="44" localId="6">
              <position x="368" y="216" />
              <connectionPointIn>
                <connection refLocalId="2" />
              </connectionPointIn>
              <condition>
                <reference name="a" />
              </condition>
            </transition>
            <transition height="44" width="44" localId="7">
              <position x="368" y="304" />
              <connectionPointIn>
                <connection refLocalId="3" />
              </connectionPointIn>
              <condition>
                <reference name="b" />
              </condition>
            </transition>
            <transition height="44" width="44" localId="8">
              <position x="300" y="216" />
              <connectionPointIn>
                <connection refLocalId="4" />
              </connectionPointIn>
              <condition>
                <reference name="a" />
              </condition>
            </transition>
          </SFC>
        </body>
      </pou>
    </pous>
  </types>
  <instances>
    <configurations>
      <configuration name="MainConfiguration">
        <resource name="MainResource">
          <pouInstance name="Grafcet" type="program" />
        </resource>
      </configuration>
    </configurations>
  </instances>
</project>
Dans ce fichier XML, seulement quelques informations m'int�ressent, ce sont les steps et les transitions, elles se situent juste apr�s la balise <SFC> (entre la ligne 51 et 112 du code ci-dessus).

Les informations que j'aimerai donc r�cup�rer sont:

- Premi�rement : le nombre total de STEP et de TRANSITION (ce nombre peut varier d'un fichier xml � un autre)

- Deuxi�mement :
* Pour chaque STEP, le "name" (string), le "localID" (int), le "refLocalId" (int) et enfin le "InitialStep" (bool).
* Pour chaque TRANSITION, le "name" (string), le "localID" (int) et le "refLocalId" (int).

Apr�s avoir vu le fichier XML, voici les fonctions de mon application que j'aimerai cr�er :

  1. Ouvrir un fichier .xml quelque soit son nom (car chaque fichier g�n�r� auparavant aura un nom diff�rent)
  2. R�cup�rer les informations dont j'ai besoin comme expliqu� un peu plus haut
  3. Traiter ces informations afin d'obtenir une matrice, mais pour l'instant cette partie n'est pas la priorit�.


J'aimerai proc�der �tape par �tape afin de bien tout comprendre et donc pour commencer, comment ouvrir un fichier .XML quelque soit son nom ?

J'ai vu que cette fonction pouvait surement convenir:
Code : S�lectionner tout - Visualiser dans une fen�tre � part
1
2
3
4
5
public: Workbook^ OpenXML(
	String^ Filename, 
	Object^ Stylesheets, 
	Object^ LoadOption
);
Mais comment lier cette fonction � un bouton du style "menu" -> "ouvrir un fichier" -> "parcourir" ?

De plus, pour r�cup�rer les informations dont j'ai besoin j'avais pens� � quelque chose du genre :
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
class step{
	public:
		string name;
		bool initialStep, negated;
		int localId, refLocalId;
};
 
class transition{
	public:
		int localId, refLocalId;
};
 
list<step> step_list;
list<transition> transition_list;
 
TiXmlHandle hdl(&doc);
TiXmlElement *elem = hdl.FirstChildElement().FirstChildElement().FirstChildElement().FirstChildElement().FirstChildElement().Element();
 
 
step cl;
if(!elem){
	cerr << "le noeud à atteindre n'existe pas" << endl;
	return 2;
}
 
while (elem){
	cl.name = elem->Attribute("name");
	cl.pass = elem->Attribute("initialStep");
	cl.pass = elem->Attribute("negated");
	elem->QueryIntAttribute("localId", &cl.droits);
	elem->QueryIntAttribute("refLocalId", &cl.droits);
	step_list.push_back(cl);
 
	elem = elem->NextSiblingElement(); // iteration 
}
 
transition cl;
if(!elem){
	cerr << "le noeud à atteindre n'existe pas" << endl;
	return 2;
}
 
while (elem){
	elem->QueryIntAttribute("localId", &cl.droits);
	elem->QueryIntAttribute("refLocalId", &cl.droits);
	transition_list.push_back(cl);
 
	elem = elem->NextSiblingElement(); // iteration 
}
 
list<step>::iterator i;
for(i=step_list.begin(); i!=step_list.end(); i++)
    cout << i->name << " " << i->initialStep << " " << i->negated << " " << i->localId << " " << i->refLocalId << endl;
 
list<transition>::iterator i;
for(i=transition_list.begin(); i!=transition_list.end(); i++)
    cout << i->localId << " " << i->refLocalId << endl;
 
 
	{
Mais je doute que �a marche, et de plus je ne sais pas o� y placer dans mon projet. Fichier.ccp ? Fichier.h ? Dans le main ?

Conclusion : I'm Lost et je pense que ce sujet pourra int�resser pas mal de personnes car j'ai fait de tr�s nombreuses recherches et je n'ai jamais trouv� quelque chose de clair mis � part m'embarquer dans d�innombrables tuto (tinyXML, xPath, Xerces etc...).

Merci d'avoir pris le temps de lire ce sujet, j'attend avec impatience vos commentaires, vos conseils et bien entendu votre aide