Bonjour,
J'ai bien installé Libxml2 dans mon projet de travail. Il me reste comment je vais l'utiliser dans mon programme C. De plus, je ne trouve pas des exemples simples sous Windows.
Je voudrais lire des informations à partir d'un fichier XML pour les utiliser après dans mon programme C. Ce fichier XML est assez volumineux. Ce fichier a une structure bien définie.
En général voici la structure de ce fichier:
On trouve :
- le type de document
- le nombre d'objets, le nombre d'attributs et le nombre des concepts
- le nom de lattice
- la liste des objets
- le liste des attributs
- la liste des concepts
Je m'intéresse à liste des concepts dans mon programme C.
Voici en général la structure de ce fichier "nom.lat.xml"
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 <Galicia_Document> <Lattice numberObj="5" numberAtt="4" numberCpt="11"> <Name>lattice(essai)</Name> <Object>3</Object> ..... <Object>4</Object> <Attribute>b</Attribute> ........ <Attribute>a</Attribute> <Concept> <ID> 1 </ID> <Extent> <Object_Ref>3</Object_Ref> <Object_Ref>2</Object_Ref> <Object_Ref>1</Object_Ref> <Object_Ref>5</Object_Ref> <Object_Ref>4</Object_Ref> </Extent> <Intent> </Intent> <UpperCovers> </UpperCovers> ........ ......... ....... <ID> 11 </ID> <Extent> </Extent> <Intent> <Attribute_Ref>d</Attribute_Ref> <Attribute_Ref>b</Attribute_Ref> <Attribute_Ref>c</Attribute_Ref> <Attribute_Ref>a</Attribute_Ref> </Intent> <UpperCovers> <Concept_Ref>10</Concept_Ref> <Concept_Ref>8</Concept_Ref> <Concept_Ref>9</Concept_Ref> <Concept_Ref>7</Concept_Ref> </UpperCovers> </Concept>
Comment je vais positionner sur le dernier identifiant <ID> 11 </ID> pour extraire toutes les valeurs de balise <Attribute_Ref> </Attribute_Ref> qui existent entre les deux balises
<Intent> </Intent> ?
<Intent>
<Attribute_Ref>d</Attribute_Ref>
<Attribute_Ref>b</Attribute_Ref>
<Attribute_Ref>c</Attribute_Ref>
<Attribute_Ref>a</Attribute_Ref>
</Intent>
Ces valeurs d, b, c et a je vais les utiliser dans mon programme C.
Aussi de même, je veux lire les valeurs 10, 8, 9 et 7 entre les deux balises <Concept_Ref> </Concept_Ref> qui existent sous les balises <UpperCovers> </UpperCovers>
<UpperCovers>
<Concept_Ref>10</Concept_Ref>
<Concept_Ref>8</Concept_Ref>
<Concept_Ref>9</Concept_Ref>
<Concept_Ref>7</Concept_Ref>
</UpperCovers>
Voici mon fichier XML complet nommé "essai.lat.xml":
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172 <Galicia_Document> <Lattice numberObj="5" numberAtt="4" numberCpt="11"> <Name>lattice(essai)</Name> <Object>3</Object> <Object>2</Object> <Object>1</Object> <Object>5</Object> <Object>4</Object> <Attribute>d</Attribute> <Attribute>b</Attribute> <Attribute>c</Attribute> <Attribute>a</Attribute> <Concept> <ID> 1 </ID> <Extent> <Object_Ref>3</Object_Ref> <Object_Ref>2</Object_Ref> <Object_Ref>1</Object_Ref> <Object_Ref>5</Object_Ref> <Object_Ref>4</Object_Ref> </Extent> <Intent> </Intent> <UpperCovers> </UpperCovers> </Concept> <Concept> <ID> 2 </ID> <Extent> <Object_Ref>1</Object_Ref> <Object_Ref>5</Object_Ref> </Extent> <Intent> <Attribute_Ref>a</Attribute_Ref> </Intent> <UpperCovers> <Concept_Ref>1</Concept_Ref> </UpperCovers> </Concept> <Concept> <ID> 5 </ID> <Extent> <Object_Ref>2</Object_Ref> <Object_Ref>5</Object_Ref> <Object_Ref>4</Object_Ref> </Extent> <Intent> <Attribute_Ref>b</Attribute_Ref> </Intent> <UpperCovers> <Concept_Ref>1</Concept_Ref> </UpperCovers> </Concept> <Concept> <ID> 4 </ID> <Extent> <Object_Ref>3</Object_Ref> <Object_Ref>1</Object_Ref> <Object_Ref>4</Object_Ref> </Extent> <Intent> <Attribute_Ref>c</Attribute_Ref> </Intent> <UpperCovers> <Concept_Ref>1</Concept_Ref> </UpperCovers> </Concept> <Concept> <ID> 3 </ID> <Extent> <Object_Ref>3</Object_Ref> <Object_Ref>2</Object_Ref> <Object_Ref>5</Object_Ref> </Extent> <Intent> <Attribute_Ref>d</Attribute_Ref> </Intent> <UpperCovers> <Concept_Ref>1</Concept_Ref> </UpperCovers> </Concept> <Concept> <ID> 8 </ID> <Extent> <Object_Ref>1</Object_Ref> </Extent> <Intent> <Attribute_Ref>c</Attribute_Ref> <Attribute_Ref>a</Attribute_Ref> </Intent> <UpperCovers> <Concept_Ref>2</Concept_Ref> <Concept_Ref>4</Concept_Ref> </UpperCovers> </Concept> <Concept> <ID> 9 </ID> <Extent> <Object_Ref>4</Object_Ref> </Extent> <Intent> <Attribute_Ref>b</Attribute_Ref> <Attribute_Ref>c</Attribute_Ref> </Intent> <UpperCovers> <Concept_Ref>5</Concept_Ref> <Concept_Ref>4</Concept_Ref> </UpperCovers> </Concept> <Concept> <ID> 6 </ID> <Extent> <Object_Ref>2</Object_Ref> <Object_Ref>5</Object_Ref> </Extent> <Intent> <Attribute_Ref>d</Attribute_Ref> <Attribute_Ref>b</Attribute_Ref> </Intent> <UpperCovers> <Concept_Ref>5</Concept_Ref> <Concept_Ref>3</Concept_Ref> </UpperCovers> </Concept> <Concept> <ID> 7 </ID> <Extent> <Object_Ref>3</Object_Ref> </Extent> <Intent> <Attribute_Ref>d</Attribute_Ref> <Attribute_Ref>c</Attribute_Ref> </Intent> <UpperCovers> <Concept_Ref>4</Concept_Ref> <Concept_Ref>3</Concept_Ref> </UpperCovers> </Concept> <Concept> <ID> 10 </ID> <Extent> <Object_Ref>5</Object_Ref> </Extent> <Intent> <Attribute_Ref>d</Attribute_Ref> <Attribute_Ref>b</Attribute_Ref> <Attribute_Ref>a</Attribute_Ref> </Intent> <UpperCovers> <Concept_Ref>2</Concept_Ref> <Concept_Ref>6</Concept_Ref> </UpperCovers> </Concept> <Concept> <ID> 11 </ID> <Extent> </Extent> <Intent> <Attribute_Ref>d</Attribute_Ref> <Attribute_Ref>b</Attribute_Ref> <Attribute_Ref>c</Attribute_Ref> <Attribute_Ref>a</Attribute_Ref> </Intent> <UpperCovers> <Concept_Ref>10</Concept_Ref> <Concept_Ref>8</Concept_Ref> <Concept_Ref>9</Concept_Ref> <Concept_Ref>7</Concept_Ref> </UpperCovers> </Concept> </Lattice> </Galicia_Document>
Donc, comment je vais lire les valeurs déjà citées à partir de ce fichier et comment je les mettre (dans des autres variables ou directement je vais les utiliser) dans mon programme ?
S'il vous plaît, Pouvez-vous m'aider ?
Merci.
Partager