Bonjour,

Je travail sur un petit programme utilisant un fichier XML contenant des informations sur des fluides.
J'essaie d'utiliser le fichier XML directement sans intermédiaire type DataGridView. (Est-ce judicieux?)

Je veux remplir des TextBoxes. Ça marche (presque) mais je me demande s'il est possible d'utiliser "lineNumber" pour aller directement 'a la ligne souhaitée et ainsi éviter le "select case.." ?

Merci de votre aide!

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
44
45
46
47
48
49
50
51
52
53
54
 
Private Sub UpdateProductProp(ByVal aProd As String)
        'show de property of a selected product
        Dim startLine As Integer = 0
        Dim aLine As Integer = 0
        Dim UpdateStart As Boolean = False
        Dim xmlDoc As New XmlTextReader(My.Settings.ProductBib)
 
        While (xmlDoc.Read() And aLine < 10) '10 = nb of prop
            Dim oType = xmlDoc.NodeType
            'check element
            If oType = XmlNodeType.Element And xmlDoc.Depth = 2 Then
                If UpdateStart = True Then
                    aLine += 1
                    Select Case aLine
                        Case 1
                            TBoxIDSel.Text = xmlDoc.ReadInnerXml
                        Case 2
                            TBoxMindTSel.Text = xmlDoc.ReadInnerXml
                        Case 3
                            TBoxMaxdTSel.Text = xmlDoc.ReadInnerXml
                        Case 4
                            TBoxMaxIndHeatSel.Text = xmlDoc.ReadInnerXml
                        Case 5
                            TBoxMaxdirHeatSel.Text = xmlDoc.ReadInnerXml
                        Case 6
                            TBoxMaxBoilTSel.Text = xmlDoc.ReadInnerXml
                        Case 7
                            TBoxMinBoilTSel.Text = xmlDoc.ReadInnerXml
                        Case 8
                            TBoxMinProdTSel.Text = xmlDoc.ReadInnerXml
                        Case 9
                            TBoxMinProConSel.Text = xmlDoc.ReadInnerXml
                        Case 10
                            TBoxMaxProConSel.Text = xmlDoc.ReadInnerXml
                    End Select
 
                    Debug.Print(aLine)
                End If
 
 
                If xmlDoc.ReadInnerXml = aProd Then
                    UpdateStart = True
                End If
            End If
        End While
 
        'TBoxIDSel.Text = xmlDoc.LineNumber(aLine + 1).readInnerXml '(xmlDoc.LineNumber(aLine + 1))
 
 
        xmlDoc.Close()
        xmlDoc = Nothing
 
    End Sub

product.xml
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
 
<?xml version="1.0" standalone="yes"?>
<Products>
  <Product>
    <Product_Name>cc</Product_Name>
    <Product_ID>2</Product_ID>
    <MindT_x00B0_C>2</MindT_x00B0_C>
    <MaxdT_x00B0_C>2</MaxdT_x00B0_C>
    <MaxIndHeatingT_x00B0_C>2</MaxIndHeatingT_x00B0_C>
    <MaxDirectHeatingT_x00B0_C>2</MaxDirectHeatingT_x00B0_C>
    <MaxBoilingT_x00B0_C>2</MaxBoilingT_x00B0_C>
    <MinBoilingT_x00B0_C>2</MinBoilingT_x00B0_C>
    <MinProductT_x00B0_C>2</MinProductT_x00B0_C>
    <MinProductConcentration_x0025_TS>2</MinProductConcentration_x0025_TS>
    <MaxProductConcentration_x0025_TS>2</MaxProductConcentration_x0025_TS>
  </Product>
  <Product>
    <Product_Name>dd</Product_Name>
    <Product_ID>3</Product_ID>
    <MindT_x00B0_C>3</MindT_x00B0_C>
    <MaxdT_x00B0_C>3</MaxdT_x00B0_C>
    <MaxIndHeatingT_x00B0_C>3</MaxIndHeatingT_x00B0_C>
    <MaxDirectHeatingT_x00B0_C>3</MaxDirectHeatingT_x00B0_C>
    <MaxBoilingT_x00B0_C>3</MaxBoilingT_x00B0_C>
    <MinBoilingT_x00B0_C>3</MinBoilingT_x00B0_C>
    <MinProductT_x00B0_C>3</MinProductT_x00B0_C>
    <MinProductConcentration_x0025_TS>3</MinProductConcentration_x0025_TS>
    <MaxProductConcentration_x0025_TS>3</MaxProductConcentration_x0025_TS>
  </Product>
</Products>