Bonjour,
je cherche à avoir la "num" qui se trouve dans "DONNEES"
Voic le XML en question:
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
 
<DONNEES num="14">
<UTILISATEUR NOM="PISSARO Camille">
  <RUE1>Rue Victor Hugo</RUE1>
  <RUE2></RUE2>
  <CODE_POSTAL>95300</CODE_POSTAL>
  <VILLE>Pontoise</VILLE> 
  <PAYS>France</PAYS>
  <REMARQUE>blabla</REMARQUE>
  <MELS>
    <ADRESSE Num="1">c.pissaro@pontoise.org</ADRESSE>
    <ADRESSE Num="2">camille.pissaro@impressioniste.pict</ADRESSE>
  </MELS>
</UTILISATEUR>
 
<UTILISATEUR NOM="COURBET Gustave">
  <RUE1>Hôtel Hébert</RUE1>
  <RUE2>Place Robert Fernier</RUE2>
  <CODE_POSTAL>25290</CODE_POSTAL>
  <VILLE>Ornans</VILLE>
  <PAYS>France</PAYS>
  <REMARQUE>blabla</REMARQUE>
  <MELS>
    <ADRESSE Num="1">g.courbet@free.fr</ADRESSE>
    <ADRESSE Num="2">gustave.courbet@patres.sky</ADRESSE>
  </MELS>
</UTILISATEUR>
 
<UTILISATEUR NOM="GEROME Jean-Léon">
  <RUE1>Musée Georges Garret</RUE1>
  <RUE2>1 bis, rue des Ursulines</RUE2>
  <CODE_POSTAL>70000</CODE_POSTAL>
  <VILLE>Vesoul</VILLE>
  <PAYS>France</PAYS>
  <REMARQUE>blabla</REMARQUE>
  <MELS>
    <ADRESSE Num="1">
      jl.gerome@wanadoo.fr
    </ADRESSE>
  </MELS></UTILISATEUR></DONNEES>
j'ai essayé en faisant cela, avec TagName_ = DONNEES et Attribute_ = num

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
 
Private Function cherche_attribut_return_int(TagName_ As String, Attribute_ As String, num As Long) As Integer
'Cette fonction permet d'afficher dans Text1 l'attribut demandé pour une balise donnée
Dim Indice As Integer
Dim le_num_return As Integer
Dim myStr As String
Dim xmlElement As MSXML2.IXMLDOMElement
Dim textNode As MSXML2.IXMLDOMElement
 Indice = 0
 
'''Debut:
Set xmlElement = xmlDoc.documentElement
        For Each textNode In xmlElement.getElementsByTagName(TagName_)
 
'            If DEBOG = 1 Then Text1 = Text1 & "Kcherche_attribut_return_int: " & textNode.getAttribute(Attribute_) & vbCrLf
 
            If Indice = num And Not (IsNull(textNode.getAttribute(Attribute_))) Then
            le_num_return = textNode.getAttribute(Attribute_)
            cherche_attribut_return_int = le_num_return
            If DEBOG = 1 Then Text1 = Text1 & "cherche_attribut_return_int: " & CStr(le_num_return) & vbCrLf
            GoTo fin_cherche_attribut_return_int
            End If
 
            If (Indice = num) And IsNull(textNode.getAttribute(Attribute_)) Then
            le_num_return = 999
            cherche_attribut_return_int = le_num_return
            If DEBOG = 1 Then Text1 = Text1 & "cherche_attribut_return_int: " & CStr(le_num_return) & vbCrLf
            GoTo fin_cherche_attribut_return_int
            End If
 
            Indice = Indice + 1
        Next
fin_cherche_attribut_return_int:
'''Fin:
 
 
End Function
mais cela me renvoi 0
merci d'avance!