John, your first attempt is close...
But, you need to set a break point on the Do While line of code and see what
your getting.
If the "<type name=" string is the first line in your XML file then the loop
will never execute the body of the loop...
[quoted text, click to view] > Do while Line not "<type name=\"lstCountry\" default=\"\"
> inherits=\"combo\" regex=\"\" regexsample=\"\">"
> Line = InputFile.ReadLine
> TextBox1.Text = Line
> Loop
>
>
> 'TextBox1.Text = InputFile.ReadToEnd()
> InputFile.Close()
> End Sub
> End Class
And, I'm not sure the loop is doing what you think. To do a Not Equal in VB
try <> (Assuming Line is a string object).
Most of the time you see Do While InputFile.Read() or Do While
InputFile.ReadLine(). Then once inside the body of your loop you can test
for each line of data rows to process or parse.
There are other option depending on what your are trying to do.
Method 1] This previous way is something you have to know how to do anyway
(Reading and parsing a file, any kind of file).
Method 2] Rick's suggestion using XML document and nodes. (I know XML but
have not played with the XML dom much).
Method 3] Create a DataSet object and load the XML file using built-in
methods from the DS to load the XML file directly into the DS. Then you can
cycle through the records in the datatable object to add them to another
DataSet or process them. Use a DataAdapter object to connected SQL Server
table. Once you update a DataTable object within a DS (DataSet) you can
update the data back to the database using the DA object. Check out the Web
for ADO code samples.
I think you have a great opportunity to learn three ways to read data from
an XML file using DotNet.
I to should do this.
JerryM