Tester l'existence d'un attribut XML
Bonjour,
Dans ma macro je manipule un fichier XML, mais je ne sais pas comment faire pour tester si un attribut spécificque existe dans une balise spécifique.
En gros, le code ci-dessous en rouge ne marche pas mais c'est ce que je cherche à faire :
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
| Sub EURUSD()
Dim xmlDoc, xmlAttrib
Dim i As Integer
Dim cond As Boolean
Set xmlDoc = CreateObject("Microsoft.XMLDOM")
xmlDoc.async = "false" ' loads file completely before doing anything on it
xmlDoc.Load ("http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml")
Set xmlAttrib = xmlDoc.getElementsByTagName("Cube")
i = 0
cond = False
While cond = False
If xmlAttrib(i).getAttribute("currency") <> Nothing Then
If xmlAttrib(i).getAttribute("currency") <> "USD" Then
i = i + 1
Else
cond = True
End If
Else
i = i + 1
End If
Wend
MsgBox xmlAttrib(i).getAttribute("rate")
Set xmlAttrib = Nothing
Set xmlDoc = Nothing
End Sub |
Savez-vous comment faire ? Sur google je ne trouve rien qui s'applique au VBA...
Par avance merci