I have an XML file, shown below:
The problem is that I want to read the complete XML file, however because I am repeating the same XMLElementName it only seems to read the first element, the code I am using is the following:Code:<?xml version="1.0" standalone="no"?> <!--RISInsight server settings--> <Configuration> <Server> <ConnectionMode>ServerName</ConnectionMode> <ServerName>(local)</ServerName> <IPAddress>NR</IPAddress> <IPPort>NR</IPPort> <SMTPServer></SMTPServer> <SMTPPort></SMTPPort> <SMTPUserName></SMTPUserName> <SMTPPassword></SMTPPassword> <LicenseFile>C:\Program Files\Ticodi\ReviewInsight\License\ReviewInsight.lic</LicenseFile> </Server> <Server> <ConnectionMode>ServerName</ConnectionMode> <ServerName>(local)</ServerName> <IPAddress>NR</IPAddress> <IPPort>NR</IPPort> <SMTPServer></SMTPServer> <SMTPPort></SMTPPort> <SMTPUserName></SMTPUserName> <SMTPPassword></SMTPPassword> <LicenseFile>C:\Program Files\Ticodi\ReviewInsight\License\ReviewInsight.lic</LicenseFile> </Server> </Configuration>
Is there a way that I can make it continue to read the XML file?Code:Dim reader As Xml.XmlTextReader = New Xml.XmlTextReader(Application.StartupPath & "\settings.ini") Do While (reader.Read()) Dim addToList As Boolean = False Select Case reader.NodeType Case Xml.XmlNodeType.Element xmlElementName = reader.Name Case Xml.XmlNodeType.Text If xmlElementName = "ConnectionMode" Then RISData.Instance.ConnectionMode = reader.Value ElseIf xmlElementName = "IPAddress" Then RISData.Instance.IPAddress = reader.Value ElseIf xmlElementName = "IPPort" Then RISData.Instance.IPPort = reader.Value addToList = True ElseIf xmlElementName = "ServerName" Then RISData.Instance.ServerName = reader.Value ElseIf xmlElementName = "LicenseFile" Then RISData.Instance.LicenseLocation = reader.Value ElseIf xmlElementName = "SMTPServer" Then RISData.Instance.SMTPServer = reader.Value ElseIf xmlElementName = "SMTPPort" Then RISData.Instance.SMTPPort = reader.Value ElseIf xmlElementName = "SMTPUserName" Then RISData.Instance.SMTPUserName = reader.Value ElseIf xmlElementName = "SMTPPassword" Then RISData.Instance.SMTPPassword = reader.Value End If If addToList = True Then Me.lstServer.BeginInit() If RISData.Instance.ConnectionMode = "ServerName" Then Dim data As Object() = New Object() {RISData.Instance.ServerName, "N/A"} Me.lstServer.Rows.Items.Add(New Node(data)) Else Dim data As Object() = New Object() {RISData.Instance.IPAddress, RISData.Instance.IPPort} Me.lstServer.Rows.Items.Add(New Node(data)) End If Me.lstServer.EndInit() addToList = False End If End Select Loop reader.Close()
Thanks in advance
Simon




Reply With Quote