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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
   | Imports Microsoft.VisualBasic
Imports System.Environment
Imports System.Xml
Imports System.IO
Imports System.Xml.XPath
Imports System.Xml.Schema
Imports System.String
 
Public Class Form1
 
    Public documentXML As XmlDocument
    Public noeuxRacine, noeuxEnf As XmlNode
    Public noeuxEnfList As XmlNodeList
    Public elementXML, elementXML2 As XmlElement
    Public texteXML As XmlText
    Public attributXML As XmlAttribute
    Public attribCollecXML As XmlAttributeCollection
    Public pathNavigator As XPathNavigator
    Public NoeuxIterateur, NoeuxIterateur2 As XPathNodeIterator
 
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
 
        Try
            documentXML = New XmlDocument               'nouveau objet XML
            documentXML.Load("C:\Documents and Settings\Administrateur\Bureau\documents thomas\licence\schneider\travail\Getex_3000\XML\sl_curan_reseau.XEF")              'mise en mémoire du projet
 
        Catch ex As XmlException
            MsgBox(ex.Message)
        End Try
    End Sub
 
    Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Try
            Dim N As Integer
            Dim M As Integer
            Dim Rang As Integer
            Dim Idx_Row As Integer = 0
            Dim Idx_Col As Integer = 0
            Dim Row(10, 20) As String
            Dim row1(6) As String
            Dim temp(10) As String
            Dim Topo_Temp As String
            Dim IP_Temp As String
            Dim Mask_Temp As String
            Dim XWay_Temp As String
 
            NoeuxIterateur = Nothing
            pathNavigator = documentXML.CreateNavigator()
            'remplissage lignes avec reférence équipemement
            NoeuxIterateur = pathNavigator.Select("//partItem[starts-with(@partNumber,'TSXETY')]")
            While (NoeuxIterateur.MoveNext())
                Rang = NoeuxIterateur.Count()
                Row(Idx_Row, 0) = NoeuxIterateur.Current.GetAttribute("partNumber", "")
                NoeuxIterateur.Current.MoveToFollowing("equipInfo", "")
                Row(Idx_Row, 1) = NoeuxIterateur.Current.GetAttribute("topoAddress", "")
                Idx_Row = Idx_Row + 1
            End While
 
            ' Selection des Réseaux Ethernet
            NoeuxIterateur = pathNavigator.Select("//ethernet[@topoAddress]")
 
            ' Recherche des adresses IP, Masques, ...
            While (NoeuxIterateur.MoveNext())
 
                'Mémorisation de l'adresse topologique de la carte
                Topo_Temp = NoeuxIterateur.Current.GetAttribute("topoAddress", "")
 
                ' Adresse IP
                Dim NoeuxIterateur2 As XPathNodeIterator
                NoeuxIterateur2 = NoeuxIterateur.Current.Select("//IPNetwork/IPAddress")
                NoeuxIterateur2.MoveNext()
                IP_Temp = Concat(NoeuxIterateur2.Current.GetAttribute("IP0", ""), ".", _
                                NoeuxIterateur2.Current.GetAttribute("IP1", ""), ".", _
                                NoeuxIterateur2.Current.GetAttribute("IP2", ""), ".", _
                                NoeuxIterateur2.Current.GetAttribute("IP3", ""))
                'NoeuxIterateur.Current.Mo()
 
                ' Masque IP
                NoeuxIterateur2 = NoeuxIterateur.Current.Select("//mask/IPAddress")
                NoeuxIterateur2.MoveNext()
                Mask_Temp = Concat(NoeuxIterateur2.Current.GetAttribute("IP0", ""), ".", _
                                NoeuxIterateur2.Current.GetAttribute("IP1", ""), ".", _
                                NoeuxIterateur2.Current.GetAttribute("IP2", ""), ".", _
                                NoeuxIterateur2.Current.GetAttribute("IP3", ""))
 
                ' Adresse XWay
                NoeuxIterateur2 = NoeuxIterateur.Current.CreateNavigator.Select("//XWayAddress")
                NoeuxIterateur2.MoveNext()
                XWay_Temp = Concat(NoeuxIterateur2.Current.GetAttribute("network", ""), ".", _
                                NoeuxIterateur2.Current.GetAttribute("station", ""))
 
                ' Affectation des paramètres sur les cartes Ethernet correspondantes
                For N = 0 To Idx_Row - 1
                    If InStr(Topo_Temp, Row(N, 1)) > 0 Then
                        Row(N, 2) = IP_Temp
                        Row(N, 3) = Mask_Temp
                        Row(N, 4) = XWay_Temp
                        Exit For
                    End If
                Next
 
            End While
 
            'ajout des lignes dans le datagridview
            With Me.DataGridView1.Rows
                .Add(Row(0, 0), Row(0, 1), Row(0, 2), Row(0, 3), Row(0, 4))
                .Add(Row(1, 0), Row(1, 1), Row(1, 2), Row(1, 3), Row(1, 4))
            End With
 
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
 
 
    End Sub
End Class | 
Partager