All I want to do, for now, is to open an XML file, read into some public variables, and close the file.
My XML structure is thus:
And so far, I haven't gotten much programmed to do this because I can't seem to figure out which method to use.
Eventually I'll add more variable types to the XML, but I need to get through the basics first.
I need the computer names in one variable, while their IP addresses in another variable. I'm going to put on my form the list of both variables (in column form), and use the IP address variable to open for listening.
All of the MSDN examples use "console.writeline", which I can't figure out how to translate into something useful for my program.
Thanks,
-Shooter
My XML structure is thus:
Code:
<?xml version="1.0" encoding="utf-8"?>
<ConfigData>
<!-- ........................................................ -->
<!-- Hardware: -->
<!-- Computer: -->
<!-- Name: Computer Name (i.e. "Senior", "Junior1") -->
<!-- Host: Static IP Address of Computer (10.10.10.20) -->
<!-- ........................................................ -->
<Hardware>
<Computers>
<Computer Name="Senior" Host="10.10.20.20"/>
<Computer Name="Junior1" Host="10.10.20.21"/>
<Computer Name="Junior2" Host="10.10.20.22"/>
<Computer Name="Office1" Host="10.10.20.30"/>
<Computer Name="Office2" Host="10.10.20.31"/>
<Computer Name="Parts1" Host="10.10.20.40"/>
<Computer Name="Parts2" Host="10.10.20.41"/>
<Computer Name="Hanger1" Host="10.10.20.50"/>
<Computer Name="Hanger2" Host="10.10.20.51"/>
<Computer Name="Hanger3" Host="10.10.20.52"/>
<Computer Name="Hanger4" Host="10.10.20.53"/>
<Computer Name="Hanger5" Host="10.10.20.54"/>
<Computer Name="Hanger6" Host="10.10.20.55"/>
<Computer Name="Hanger7" Host="10.10.20.56"/>
</Computers>
</Hardware>
</ConfigData>
And so far, I haven't gotten much programmed to do this because I can't seem to figure out which method to use.
Code:
Imports System.Xml
Imports System.IO
Imports System.Net.Sockets
Imports System.Text
Public Class xmlFormReader
Public compName() As String
Public compHost() As String
Private Sub xmlFormReader_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
readXML("configdata.xml")
End Sub
Private Sub readXML(ByVal fileName As String)
'Write code here to open the file, parse the variables, and close the file
End Sub
End Class
I need the computer names in one variable, while their IP addresses in another variable. I'm going to put on my form the list of both variables (in column form), and use the IP address variable to open for listening.
- Which method should I use to open the file as an XML?
- Which method should I use to parse the variables, and how?
All of the MSDN examples use "console.writeline", which I can't figure out how to translate into something useful for my program.
Thanks,
-Shooter