Bonjour à tous.
Je suis nouveau sur votre site. Bravo à tous ceux qui fabriquent ces ressources.
Voilà mon problème.
J'ai un fichier xml de cette forme.
Code xml : 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 <?xml version="1.0" ?> - <xml_api_reply version="1"> - <weather module_id="0" tab_id="0" mobile_row="0" mobile_zipped="1" row="0" section="0"> - <forecast_information> <city data="Lillebonne, Upper-Normandy" /> <postal_code data="Lillebonne" /> <latitude_e6 data="" /> <longitude_e6 data="" /> <forecast_date data="2010-12-02" /> <current_date_time data="2010-12-02 22:20:27 +0000" /> <unit_system data="SI" /> </forecast_information> - <current_conditions> <condition data="Averses de neige" /> <temp_f data="27" /> <temp_c data="-3" /> <humidity data="Humidité : 91 %" /> <icon data="/ig/images/weather/snow.gif" /> <wind_condition data="Vent : N à 3 km/h" /> </current_conditions> - <forecast_conditions> <day_of_week data="jeu." /> <low data="-3" /> <high data="-2" /> <icon data="/ig/images/weather/partly_cloudy.gif" /> <condition data="Couverture nuageuse partielle" /> </forecast_conditions> - <forecast_conditions> <day_of_week data="ven." /> <low data="-2" /> <high data="1" /> <icon data="/ig/images/weather/partly_cloudy.gif" /> <condition data="Couverture nuageuse partielle" /> </forecast_conditions> - <forecast_conditions> <day_of_week data="sam." /> <low data="-1" /> <high data="6" /> <icon data="/ig/images/weather/rain_snow.gif" /> <condition data="Pluie et Neige" /> </forecast_conditions> - <forecast_conditions> <day_of_week data="dim." /> <low data="2" /> <high data="6" /> <icon data="/ig/images/weather/rain.gif" /> <condition data="Pluie" /> </forecast_conditions> </weather> </xml_api_reply>
C'est un fichier xml généré par une api google qui renvoie la météo sur 4 jours.
Je voudrais extraire les données de ce fichier avec un script vbs.
J'ai suivi le tuto donné sur votre site. mais je n'arrive pas à récupérer les champs.
La différence par rapport à votre tuto, les balises sont fermées .
Voici mon début de solution :
J'ai bien la boite de dialogue qui s'ouvre 4 fois, mais il n'y a rien dedans.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13 Sub main() Set xmlDoc=CreateObject("Microsoft.XMLDOM") xmlDoc.Async="false" xmlDoc.Load("C:\Program Files\Homeseer HS2\html\pages\data\meteo\meteo.xml") For Each conditionElement In xmlDoc.selectNodes("/xml_api_reply/weather/forecast_conditions") low=conditionElement.selectSingleNode("low").text msgbox low Next Set xmlDoc=Nothing end sub
Merci de votre aide.
Boboss76
Cordialement
![]()
Partager