Bonjour a tous.


Je suis coincé au niveau de l'extraction de données a partir d'un xml.

Je m'explique,j'ai un dossier avec 250000 fichiers xml je dois extraire pour chacun certaine valeur et les insérer dans une DB SQL.

Mon probleme est le suivant je ne connais pas la méthode pour permettre a mon programme de regarder une autre balise xml si celle qu'il devait controler n'existe pas.

Par exemple dans mon code :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
iter.Current.SelectSingleNode("ED_SPEC_CH")
"ED_SPEC_CH" n'existe pas dans mon xml mais "ED_SPEC_CH2" existe et je dois la récupérer.

Et bien sur comme il ne trouve pas "ED_SPEC_CH" j'ai le droit a un NullReferenceException


merci

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
41
42
43
Case "EL"
 
                        Dim mycurrentprocat As New Notices
                        mycurrentprocat = LgNotices.Item(lgTes)
 
 
                        If Not LgNotices2.ContainsKey(lgTes) Then
                            mycurrentprocat = New Notices
                            tomeTes = iter.Current.SelectSingleNode("ED_SPEC_CH").Value
                            mycurrentprocat.tomeTes = tomeTes
                            LgNotices2.Add(lgTes, mycurrentprocat)
                        End If
 
                        If Not LgNotices2.ContainsKey(lgTes) Then
                            mycurrentprocat = New Notices
                            volumeTes = iter.Current.SelectSingleNode("ED_SPEC_V").Value
                            mycurrentprocat.volumeTes = volumeTes
                            LgNotices2.Add(lgTes, mycurrentprocat)
                        End If
 
                        If Not LgNotices2.ContainsKey(lgTes) Then
                            mycurrentprocat = New Notices
                            pageDebTes = iter.Current.SelectSingleNode("ED_SPEC_P").Value
                            mycurrentprocat.pageDebTes = pageDebTes
                            LgNotices2.Add(lgTes, mycurrentprocat)
                        End If
 
 
                        idJotTes = getJoIdTes(tomeTes, volumeTes, anneeJot)
                        mycurrentprocat.idJotTes = idJotTes
 
 
 
                        insertTitreEdSpec( _
                                        nomficNoticeTes, _
                                        lgTes, _
                                        mycurrentprocat.idJoTes, _
                                        mycurrentprocat.idCelexTes, _
                                        mycurrentprocat.tomeTes, _
                                        mycurrentprocat.volumeTes, _
                                        mycurrentprocat.pageDebTes, _
                                        mycurrentprocat.titreTitTes, _
                                        mycurrentprocat.idJotTes)