Bonjour,
J'aimerai créer un programme qui transfères des données d'un fichier XML dans un classeur Excel tous ceci en VB.NET, est ce que quelqu'un aurai une idée?
Merci d'avance !!
Version imprimable
Bonjour,
J'aimerai créer un programme qui transfères des données d'un fichier XML dans un classeur Excel tous ceci en VB.NET, est ce que quelqu'un aurai une idée?
Merci d'avance !!
Pour l'instant mon code est :
Il devrait m'afficher un un message box non ??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
33
34
35
36 Imports System.Xml Imports System.IO Public Class Form1 Public Sub Form1() 'creation d'une nouvelle instance du membre xmldocument Dim XmlDoc As XmlDocument = New XmlDocument() XmlDoc.Load("C:\Users\Philippe\Documents\speechexec\a_finish\philippe069.ds2.xml") Dim element As XmlNodeList element = XmlDoc.DocumentElement.GetElementsByTagName("NewDataSet") Dim noeud, noeudEnf As XmlNode Dim UrlSite As String Dim NomSite As String For Each noeud In element For Each noeudEnf In noeud.ChildNodes If noeudEnf.LocalName = "PropertyIdentifier" Then UrlSite = noeudEnf.InnerText Else If (noeudEnf.LocalName = "PropertyValue") Then NomSite = noeudEnf.InnerText End If End If MsgBox(NomSite & " à " & UrlSite) Next Next End Sub End Class
Ton code de récupération me semble correct, as-tu bien un fichier xml contenant ce genre de données ? :
Code:
1
2
3
4
5
6
7
8
9 <NewDataSet> <PropertyIdentifier>testId</URL> <PropertyValue>testValue</NOM> </NewDataSet> <NewDataSet> <PropertyIdentifier>testId2</URL> <PropertyValue>testValue2</NOM> </NewDataSet> ...
Oui comme ceci :
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 <?xml version="1.0" standalone="yes"?> <NewDataSet> <DictationProperties> <PropertyIdentifier>SpecialInstructionsLength</PropertyIdentifier> <PropertyValue>0</PropertyValue> </DictationProperties> <DictationProperties> <PropertyIdentifier>DictationLength</PropertyIdentifier> <PropertyValue>2624</PropertyValue> </DictationProperties> <DictationProperties> <PropertyIdentifier>CreationDateTime</PropertyIdentifier> <PropertyValue>2010-01-28 09:16:18</PropertyValue> </DictationProperties> ...
Essaye ceci :
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
33
34
35
36 Imports System.Xml Imports System.IO Public Class Form1 Public Sub Form1() 'creation d'une nouvelle instance du membre xmldocument Dim XmlDoc As XmlDocument = New XmlDocument() XmlDoc.Load("C:\Users\Philippe\Documents\speechexec\a_finish\philippe069.ds2.xml") Dim element As XmlNodeList element = XmlDoc.DocumentElement.GetElementsByTagName("DictationProperties") Dim noeud, noeudEnf As XmlNode Dim UrlSite As String Dim NomSite As String For Each noeud In element For Each noeudEnf In noeud.ChildNodes If noeudEnf.LocalName = "PropertyIdentifier" Then UrlSite = noeudEnf.InnerText Else If (noeudEnf.LocalName = "PropertyValue") Then NomSite = noeudEnf.InnerText End If End If MsgBox(NomSite & " à " & UrlSite) Next Next End Sub End Class
Mais je n'ai pas de message box qui s'affiche, est ce normal??
Non, as-tu essayé en mode debug ??
Regarde s'il passe bien dans la boucle element ...
C'est bon, j'ai réussi. Maintenant j'aimerai envoyer les données que je récupère, dans un fichier Excel, est ce possible ?