Bonjour à toutes et à tous,
Voici mon problème :
J'ai un fichier XML tel :
Voici comment je le lis :
Code xml : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11 <Racine> <Windows> <MachineName>LLUXSDMZ022</MachineName> <SerialNumber>GB8601VKJR</SerialNumber> <Domain>Domaine: DMZ</Domain> <Manufacturer>HP</Manufacturer> <Os>Microsoft(R) Windows(R) Server 2003, Enterprise Edition</Os> <Version>3790</Version> <Description /> <ServicePack>1</ServicePack> </Windows>
Ce code ne pose aucun problème.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12 For Each nodeParent In xmlDoc.selectNodes("/Racine/Windows") wscript.Echo nodeParent.selectSingleNode("MachineName").text wscript.Echo nodeParent.selectSingleNode("SerialNumber").text wscript.Echo nodeParent.selectSingleNode("Domain").text wscript.Echo nodeParent.selectSingleNode("Manufacturer").text wscript.Echo nodeParent.selectSingleNode("Os").text wscript.Echo nodeParent.selectSingleNode("Version").text wscript.Echo nodeParent.selectSingleNode("Description ").text wscript.Echo nodeParent.selectSingleNode("ServicePack").text Next
Ce que je voudrais pouvoir faire, c'est faire une boucle sur chacun des nodes (MachineName, SerialNumber, ...) sans devoir faire un SELECTSINGLENODE en précisant le nom du noeud.
Ensuite, dans cette boucle j'aimerais pouvoir afficher le nom du noeud et sa valeur.
J'ai trouvé une piste telle :
Mais cela ne me donne pas les résultats souhaités.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8 For Each nodeParent In xmlDoc.selectNodes("/Racine/Windows") For Each nodeEnfant In nodeParent.ChildNodes WScript.Echo "Enfant: " & nodeEnfant.text Next Next
Je ne trouve pas non plus quelles propriétés utiliser.
Peut être que cette piste n'est pas bonne non plus![]()
Partager