(Note I have posted to this group because I had no luck in
microsoft.public.dotnet.vb.general)
Hi all
This is probably an easy one... I would like to serialize an array to
an XML file but I cant quite get it right.
Here goes
I declare the array at the top of the class
Private marrApplications(100) As App
Then when I go to write the array...
Private Sub save_Applications()
'serialize the object
Dim oXS As XmlSerializer = New XmlSerializer(GetType(App))
Dim oStmW As StreamWriter
Dim i As Integer
Try
oStmW = New StreamWriter(Application.StartupPath.ToString&
"\\Applications.xml")
For i = 0 To m_applicationCount - 1
oXS.Serialize(oStmW, marrApplications(i))
Next
oStmW.Close()
Catch ex As Exception
Debug.Write(ex.Message)
End Try
End Sub
It sort of saves the array but it is not properly formed in XML. Here
is the result...
<?xml version="1.0" encoding="utf-8"?>
<Class_App xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Property_Name>Blah</Property_Name>
<Property_ConnectionString>Blah</Property_ConnectionString>
<Property_ConnectionCount>0</Property_ConnectionCount>
<Property_MaxConnections>100</Property_MaxConnections>
</Class_App><?xml version="1.0" encoding="utf-8"?>
<Class_App xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Property_Name>Blah</Property_Name>
<Property_ConnectionString>Blah</Property_ConnectionString>
<Property_ConnectionCount>0</Property_ConnectionCount>
<Property_MaxConnections>100</Property_MaxConnections>
</Class_App>
I know this isnt right but what am I doing wrong?
Any help will be much appreciated, thanks.
John.